本文整理汇总了PHP中FormField::add_desc方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::add_desc方法的具体用法?PHP FormField::add_desc怎么用?PHP FormField::add_desc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormField
的用法示例。
在下文中一共展示了FormField::add_desc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _render
/**
* The actual rendering.
*
* @param array $args
*
* @return string
*/
protected function _render($args)
{
$args = wp_parse_args($args, array('value' => '', 'desc_pos' => 'after', 'extra' => array('class' => 'regular-text')));
$values = maybe_unserialize($args['value']);
$opts = '<div class="ae_gallery_field" id="' . uniqid() . '">';
$opts .= '<script class="data-args">' . wp_json_encode($args) . '</script>';
$opts .= '<script class="data-value">' . wp_json_encode($values) . '</script>';
$opts .= '</div>';
return FormField::add_desc($opts, $args['desc'], $args['desc_pos']);
}
示例2: _render
/**
* Generate the corresponding HTML for a field.
*
* @param array $args
*
* @return string
*/
protected function _render($args)
{
$args = wp_parse_args($args, array('numeric' => false, 'checked' => null));
if (!is_array($args['checked'])) {
$args['checked'] = array();
}
$opts = '';
foreach ($args['choices'] as $value => $title) {
$single_input = FormField::_checkbox(array('name' => $args['name'] . '[]', 'type' => 'checkbox', 'value' => $value, 'checked' => in_array($value, $args['checked']), 'desc' => $title, 'desc_pos' => 'after'));
$opts .= str_replace(FormBuilder::TOKEN, $single_input, $args['wrap_each']);
}
return FormField::add_desc($opts, $args['desc'], $args['desc_pos']);
}
示例3: _render_specific
/**
* Generate the corresponding HTML for a field.
*
* @param array $args
*
* @return string
*/
protected function _render_specific($args)
{
if (array('foo') === $args['selected']) {
// radio buttons should always have one option selected
$args['selected'] = key($args['choices']);
}
$opts = '';
foreach ($args['choices'] as $value => $title) {
$value = (string) $value;
$single_input = FormField::_checkbox(array('name' => $args['name'], 'type' => 'radio', 'value' => $value, 'checked' => $value == $args['selected'], 'desc' => $title, 'desc_pos' => 'after'));
$opts .= str_replace(FormBuilder::TOKEN, $single_input, $args['wrap_each']);
}
return FormField::add_desc($opts, $args['desc'], $args['desc_pos']);
}
示例4: _render
/**
* The actual rendering.
*
* @param array $args
*/
protected function _render($args)
{
$args = wp_parse_args($args, array('value' => '', 'desc_pos' => 'after', 'extra' => array('class' => 'regular-text')));
$values = maybe_unserialize($args['value']);
$opts = '';
foreach ($values as $index => $group) {
$group_id = 'group_' . $index;
$opts .= '<div id="' . $group_id . '">';
if (is_array($group)) {
foreach ($group as $key => $value) {
$single_input = FormField::_input_gen(array('name' => $args['name'] . '[' . $index . '][' . $key . ']', 'type' => 'text', 'value' => $value, 'desc' => $key, 'desc_pos' => 'before'));
$opts .= '<br>' . str_replace(FormBuilder::TOKEN, $single_input, $args['wrap_each']);
}
$opts .= '<button class="btnRemoveRule" data-id="' . $group_id . '">Remove</button></div>';
}
}
$opts .= '<button class="btnAddRule" data-count="' . count($values) . '">Add</button>';
return FormField::add_desc($opts, $args['desc'], $args['desc_pos']);
}