当前位置: 首页>>代码示例>>PHP>>正文


PHP Label::add方法代码示例

本文整理汇总了PHP中Label::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Label::add方法的具体用法?PHP Label::add怎么用?PHP Label::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Label的用法示例。


在下文中一共展示了Label::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderFormFieldContent

 private function renderFormFieldContent($renderApi, $unit)
 {
     $this->formSubmit = new \FormSubmit();
     $fieldId = 'field' . $unit->getId();
     $properties = $unit->getFormValues();
     $labelText = $properties["fieldLabel"];
     $listType = $properties["listType"];
     //select, checkbox, radio
     $postRequest = $this->getPostValue($unit);
     $choiceBox = new \ChoiceBox();
     if ($listType === \ListType::RADIO || $listType === \ListType::CHECKBOX) {
         $required = $renderApi->getFormValue($unit, 'enableRequired');
         $formField = $choiceBox->getRadioCheckbox($renderApi, $unit, $fieldId, $postRequest, $required);
     } elseif ($listType === \ListType::DROP_DOWN) {
         $formField = $choiceBox->getSelectField($renderApi, $unit, $fieldId, $postRequest);
     }
     $label = new \Label();
     $labelProperties = $label->getElementProperties();
     $labelProperties->addAttribute("for", $fieldId);
     $label->add(new \Span($labelText));
     if ($formField) {
         $elementProperties = $formField->getElementProperties();
         $wrapper = new \Container();
         $wrapper->add($label);
         $wrapper->add($formField);
         echo $wrapper->renderElement();
     }
     $renderApi->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:29,代码来源:rz_form_field_select.php

示例2: getRadioCheckbox

 public function getRadioCheckbox($renderApi, $unit, $fieldId, $postRequestValue = null, $required = false)
 {
     $formField = new \Fieldset();
     $listOptions = $this->listOptions->getListOptions($renderApi, $unit);
     $inputName = strlen($renderApi->getFormValue($unit, 'inputName')) > 0 ? $renderApi->getFormValue($unit, 'inputName') . "[]" : $fieldId . "[]";
     if ($listOptions->hasOptions()) {
         $optionCount = 0;
         $options = $listOptions->getOptions();
         $optionsLength = count($options);
         foreach ($options as $option) {
             /* @var $option \Option */
             $properties = $unit->getFormValues();
             if ($properties["listType"] === \ListType::RADIO) {
                 $choiceField = new \RadioButtonField();
             } elseif ($properties["listType"] === \ListType::CHECKBOX) {
                 $choiceField = new \CheckboxField();
             }
             $optionId = $fieldId . '_' . $optionCount;
             $elementProperties = $choiceField->getElementProperties();
             $elementProperties->addAttribute("value", $option->getValue());
             $elementProperties->addAttribute("name", $inputName);
             $elementProperties->addAttribute("id", $optionId);
             // set required attribute for radio options or when there is only one checkbox
             // don't set for multiple checkboxes to match server-side validation logic
             if ($required && ($properties["listType"] === \ListType::RADIO || $optionsLength === 1)) {
                 $elementProperties->addAttribute("required", null);
             }
             $request = new Request();
             $request->isPostRequest();
             if (!$request->isPostRequest() && $option->isChecked() || !is_null($postRequestValue) && in_array($option->getValue(), $postRequestValue)) {
                 $elementProperties->addAttribute("checked", null);
             }
             $label = new \Label();
             $label->add($choiceField);
             $label->add(new \Span($option->getName()));
             $labelProperties = $label->getElementProperties();
             $labelProperties->addAttribute("for", $optionId);
             $formField->add($label);
             $optionCount++;
         }
     }
     if ($this->formSubmit->isValid($renderApi, $unit) && !$this->isValidValue($unit, $postRequestValue)) {
         $formField->add($this->getErrorMessage($unit, $postRequestValue));
         $formField->getElementProperties()->addClass('vf__error');
     }
     return $formField;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:47,代码来源:ChoiceBox.php

示例3: renderFormFieldContent

 private function renderFormFieldContent($renderApi, $unit)
 {
     $this->formSubmit = new \FormSubmit();
     $fieldId = 'field' . $unit->getId();
     $properties = $unit->getFormValues();
     $labelText = $properties["fieldLabel"];
     $fieldType = $properties["textType"];
     //input,list,textarea
     $postRequest = $this->getPostValue($unit);
     if ($properties['type'] === \InputType::STRING && $fieldType !== FieldType::TEXTAREA || $properties['type'] === \InputType::EMAIL || $properties['type'] === \InputType::NUMERIC) {
         $formField = new \TextField();
         $elementProperties = $formField->getElementProperties();
         $elementProperties->setId($fieldId);
         $elementProperties->addAttribute("name", $fieldId);
         $elementProperties->addAttribute('value', $postRequest);
         if (isset($properties['type'])) {
             if ($properties['type'] === \InputType::EMAIL) {
                 $elementProperties->addAttribute("type", \InputType::EMAIL);
             }
             if ($properties['type'] === \InputType::NUMERIC) {
                 $elementProperties->addAttribute("type", \InputType::NUMERIC);
             }
         }
     } elseif ($fieldType === FieldType::TEXTAREA) {
         $formField = new \TextareaField();
         $elementProperties = $formField->getElementProperties();
         $elementProperties->setId($fieldId);
         $elementProperties->addAttribute("name", $fieldId);
         $formField->setContent($postRequest);
     }
     $label = new \Label();
     $labelProperties = $label->getElementProperties();
     $labelProperties->addAttribute("for", $fieldId);
     $label->add(new \Span($labelText));
     if ($formField) {
         $wrapper = new \Container();
         $wrapper->add($label);
         $wrapper->add($formField);
         $elementProperties = $formField->getElementProperties();
         if ($this->formSubmit->isValid($renderApi, $unit) && !$this->isValidValue($unit, $postRequest)) {
             $elementProperties->addClass('vf__error');
             $wrapper->add($this->getErrorMessage($unit, $postRequest));
         }
         $this->setRequiredField($renderApi, $unit, $elementProperties);
         $this->setPlaceholderText($renderApi, $unit, $elementProperties);
         echo $wrapper->renderElement();
     }
     $renderApi->renderChildren($unit);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:49,代码来源:rz_form_field_text.php


注:本文中的Label::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。