Returns selector of radio-button's validation error

@param string $formName      Name of form (value of the "name" attribute)
@param int    $fieldSetIndex Index/Position of the field-set
@return string
181229
public static function getRadioButtonErrorSelector($formName, $fieldSetIndex)
    {
        $fieldSetSelector = CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex);

        if (empty($fieldSetSelector)) {
            return '';
        }

        $errorContainerSelector = static::getFieldErrorContainerSelector();

        return sprintf('%s legend.col-form-label %s', $fieldSetSelector, $errorContainerSelector);
    }
1291532
public function getField($fieldName)
    {
        if (array_key_exists($fieldName, $this->_message)) {
            return $this->_message[$fieldName];
        } else {
            return null;
        }
    }
301807
final public function getFormData(string $formExpression): array
    {
        $form = $this->page->object($formExpression, true)->first();
        if ($form === null) {
            throw new \InvalidArgumentException('Cant find form. Possible invalid expression ');
        }

        $formData = [];
        # textarea
        foreach ($form->element('//textarea') as $textArea) {
            $formData[$textArea->getAttribute('name')] = $textArea->nodeValue;
        }

        # radio and checkboxes
        foreach ($form->element('//input[@checked]') as $textArea) {
            $formData[$textArea->getAttribute('name')] = $textArea->getAttribute('value');
        }

        # hidden, text, submit
        $hiddenAndTextElements = $form->element('//input[@type="hidden" or @type="text" or @type="submit" or not(@type)]');
        foreach ($hiddenAndTextElements as $element) {
            $formData[$element->getAttribute('name')] = $element->getAttribute('value');
        }

        # selects
        foreach ($form->object('//select[not(@multiple)]', true) as $select) {
            $name = $select->value('//select/@name')->first();
            if ($name === null) {
                continue;
            }
            $formData[$name] = $select->value('//option[@selected]/@value')->first();
        }

        # multiple selects
        foreach ($form->object('//select[@multiple]', true) as $multipleSelect) {
            $name = $multipleSelect->value('//select/@name')->first();
            if ($name === null) {
                continue;
            }
            $options = $multipleSelect->value('//option[@selected]/@value');
            if (preg_match('!\[\]$!', $name)) {
                $name = rtrim($name, '[]');
                $formData[$name] = $options->all();
            } else {
                $formData[$name] = $options->last();
            }
        }
        return $formData;
    }
958727
protected function getElementId(Form $form)
    {
        /** @var Form $parent */
        $parent = $form->getParent();
        if (null !== $parent) {
            return $this->getElementId($parent) . '_' . $form->getName();
        } else {
            return $form->getName();
        }
    }
1175166
public function getErrorMessages(Form $form)
    {
        $errors = '';

        foreach ($form->getErrors() as $key => $error) {
            $errors .= $error->getMessage().', ';
        }

        /** @var Form $child */
        foreach ($form->all() as $child) {
            if (!$child->isValid()) {
                $fieldName = $child->getConfig()->getOption('label', null);

                if (empty($fieldName)) {
                    $fieldName = $child->getName();
                }

                $errors .= sprintf("[%s] %s, ", $fieldName, $this->getErrorMessages($child));
            }
        }

        return rtrim($errors, ', ');
    }
565688
public static function getFieldGroupSelector($formName)
    {
        $formSelector = CssSelector::getFormByNameSelector($formName);

        if (empty($formSelector)) {
            return '';
        }

        return sprintf('%s .form-group', $formSelector);
    }
1351022
protected function getValidatorForField($formKey)
    {
        $validator = null;
        if( isset($this->schema[$formKey]['options']['validator']) ) {
            $validator = $this->schema[$formKey]['options']['validator'];
            if(!is_callable($validator)) {
                $validator = null;
            }
        }
        return $validator;
    }
1208007
public function error($fieldName, $str)
    {
        // by using this hook you can overwrite default behavior of this method
        if ($this->hookHasCallbacks('displayError')) {
            return $this->hook('displayError', [$fieldName, $str]);
        }

        $jsError = [$this->js()->form('add prompt', $fieldName, $str)];

        return $jsError;
    }
433175
protected function getErrorsFromForm(FormInterface $form)
    {
        $errors = [];
        /** @var FormError $error */

        if($form->getErrors()->count() === 0 && $form->isRoot() && !$form->isValid()){
            $errors["_self"] = "Empty post data";
        }

        foreach ($form->getErrors() as $error) {
            $key = $error->getOrigin()->getName();
            $errors[($form->isRoot()) ? "_self" : $key] = $error->getMessage();
        }

        foreach ($form->all() as $childForm) {
            if ($childForm instanceof FormInterface) {
                if ($childErrors = $this->getErrorsFromForm($childForm)) {
                    unset($errors["_self"]);
                    $errors = array_merge_recursive($errors, $childErrors);
                }
            }
        }

        return $errors;
    }
1242681
private function getFormPath($formName)
    {
        $formPath = preg_split("/(\[|\])/", $formName);
        foreach ($formPath as $key => $value) {
            if ($value === '') {
                unset($formPath[$key]);
            }
        }
        return $formPath;
    }
700657
public function getErrors($fieldName=null)
    {
        if ($fieldName === null) {
            return $this->errors;
        }

        if (isset($this->errors[$fieldName])) {
            return $this->errors[$fieldName];
        }

        return [];
    }
776321
protected function getRuleClassName(string $name): string
	{
		if(!isset($this->rules[$name]))
		{
			throw new RuntimeException(vsprintf('Call to undefined validation rule [ %s ].', [$name]));
		}

		return $this->rules[$name];
	}
339731
protected function SetRequired($name, $errorPrefix = '')
    {
        $field = $this->GetElement($name);
        if (!$field instanceof FormField)
        {
            throw new \InvalidArgumentException("$name is not a field in the form elements");
        }
        if (!$errorPrefix)
        {
            $errorPrefix = $this->ErrorPrefix($name);
        }
        $field->SetRequired($errorPrefix);
    }
41356
public function getFormControlByName(string $name): Control
  {
    $control = $this->findFormControlByName($name);
    if ($control===null)
    {
      throw new LogicException("Form control with name '%s' does not exists.", $name);
    }

    return $control;
  }
1186817
static public function wx_contents_input($form_name, $form_value=null, $settings=null)
    {
        $settings['id']     = isset($settings['id']) ? $settings['id'] : str_replace(array('[', ']'), array('_'), $form_name);
        $index = 0;
        $template = <<<INPUT
<li style="%s" class="%s">
    <img src="%s" class="content-img">
    <div class="content-body">
        <span class="content-title">%s</span>
        <span class="content-description">%s</span>
        <input type="hidden" name="%s" value="%s" class="content-title-input">
        <input type="hidden" name="%s" value="%s" class="content-description-input">
        <input type="hidden" name="%s" value="%s" class="content-pic-url-input">
        <input type="hidden" name="%s" value="%s" class="content-url-input">
        <input type="hidden" name="%s" value="%s" class="content-id-input">
    </div>
    <div class="content-op">
        <input type="button" class="btn btn-primary btn-sm edit-content" value="编辑">
        <input type="button" class="btn btn-primary btn-sm delete-content" value="删除">
    </div>
</li>
INPUT;
        $str = '<ul class="list-unstyled contents-wrap">' . PHP_EOL;
        if (isset($form_value) && is_array($form_value)) foreach ($form_value as $k => $v) {
            $img_src = isset($v['pic_url']) ? $v['pic_url'] : '';
            $title = isset($v['title']) ? $v['title'] : '';
            $description = isset($v['description']) ? $v['description'] : '';
            $url = isset($v['url']) ? $v['url'] : '';
            $id  = isset($v['id']) ? $v['id'] : 0;
            $str .= sprintf($template
                , '', $settings['id'] . '-content-wrap-' . $index
                , $img_src, $title, $description
                , $settings['id'] . '['. $index . '][title]', $title
                , $settings['id'] . '['. $index . '][description]', $description
                , $settings['id'] . '['. $index . '][pic_url]', $img_src
                , $settings['id'] . '['. $index . '][url]', $url
                , $settings['id'] . '['. $index . '][id]', $id
            );
            $index += 1;
        }
        $str .= sprintf($template
            , 'display:none;', $settings['id'] . '-content-wrap-' . 'x'
            , '', '', ''
            , $settings['id'] . '['. 'x' . '][title]', ''
            , $settings['id'] . '['. 'x' . '][description]', ''
            , $settings['id'] . '['. 'x' . '][pic_url]', ''
            , $settings['id'] . '['. 'x' . '][url]', ''
            , $settings['id'] . '['. 'x' . '][id]', 0
        );
        $str .= '</ul>' . PHP_EOL;
        
        $str .= '<div style="margin-top:15px;">'. PHP_EOL;
        $str .= '    <input type="button" class="btn btn-warning btn-sm select-content" data-id="' . $settings['id'] . '" value="选择图文列表">';
        $str .= '    <input type="button" class="btn btn-warning btn-sm add-content" data-id="' . $settings['id'] . '" value="自定义图文列表">';
        $str .= '</div>'. PHP_EOL;
        
        //if (!static::$isLoadedImageText) {
        $select_url = isset($settings['modal_url']) ? $settings['modal_url'] : Ioc::url('common/data/select_content');
            $innerJs = <<<EOF
                <script>
                require(["util"], function(){
                    var index = "{$index}";
                	$(".contents-wrap").on("click", ".delete-content", function() {
                	    //console.log($(this));
                        $(this).parent().parent("li").remove();
                        return false;
                    });
                    $(".select-content").on("click", function() {
                        var tid = $(this).attr('data-id');
                        
                        var dlg = util.dialog.show({
                            width: '800px',
                    		title: '选择图文内容',
                    		url: "{$select_url}",
                    		okValue: '确 定',
                    		ok: false,
                    		cancelValue: '取消',
                    		cancel: null,
                    		cancelDisplay: true
                    	});
                    	
                        dlg.addEventListener('close', function () {
                            if (dlg.returnValue.data) {
                                console.log(dlg.returnValue);
                                data = dlg.returnValue.data;
                                if (data.length > 0) {
                    		        for (dindex in data) {
                    		            var item_index = Number(dindex) + Number(index);
                                        var tpl_ele = $("." + tid + '-content-wrap-x');
                                        var html = tpl_ele.html().replace(/\[x\]/g, '[' + item_index + ']');
                                        $('<li style="text-align:center;" class="' + tid + '-content-wrap-' + item_index + '">').insertBefore(tpl_ele).html(html);
                                        var ele = $("." + tid + '-content-wrap-' + item_index);
                                        ele.find(".content-img").attr('src', data[dindex]["pic_url"]).show();
                    		            ele.find(".content-title").html(data[dindex]["title"]);
                    		            ele.find(".content-description").html(data[dindex]["description"]);
                    		    
                                        ele.find(".content-title-input").val(data[dindex]["title"]);
                    		            ele.find(".content-description-input").val(data[dindex]["description"]);
                    		            ele.find(".content-pic-url-input").val(data[dindex]["pic_url"]);
                    		            ele.find(".content-url-input").val(data[dindex]["url"]);
                                    }
                    		        index = Number(index) + data.length;
                                }
                            }
                    	});
                        
                    });
                });
                </script>
EOF;
            $str .= $innerJs;
            // 动态的添加该输入框时脚本不能作用，暂时先重复脚本生成
            //static::$isLoadedImageText = true;
        //}
        return $str;
    }
537811
public function prepareFieldName(string $fieldName) : string
    {
        $fieldNames = $this->prepareQueryElement($fieldName, null, null, false);

        return $fieldNames[0][0];
    }
43992
public function getFormConfiguration($formClassName)
    {
        $formzConfiguration = $this->getExtensionConfiguration();

        return (isset($formzConfiguration['forms'][$formClassName]))
            ? $formzConfiguration['forms'][$formClassName]
            : [];
    }