本文整理汇总了PHP中acf_get_hidden_input函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_get_hidden_input函数的具体用法?PHP acf_get_hidden_input怎么用?PHP acf_get_hidden_input使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_get_hidden_input函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acf_hidden_input
function acf_hidden_input($atts)
{
echo acf_get_hidden_input($atts);
}
示例2: render_field
function render_field($field)
{
// vars
$i = 0;
$e = '';
$ul = array('class' => 'acf-radio-list', 'data-allow_null' => $field['allow_null'], 'data-other_choice' => $field['other_choice']);
// append to class
$ul['class'] .= ' ' . ($field['layout'] == 'horizontal' ? 'acf-hl' : 'acf-bl');
$ul['class'] .= ' ' . $field['class'];
// select value
$checked = '';
$value = strval($field['value']);
// selected choice
if (isset($field['choices'][$value])) {
$checked = $value;
// custom choice
} elseif ($field['other_choice'] && $value !== '') {
$checked = 'other';
// allow null
} elseif ($field['allow_null']) {
// do nothing
// select first input by default
} else {
$checked = key($field['choices']);
}
// ensure $checked is a string (could be an int)
$checked = strval($checked);
// other choice
if ($field['other_choice']) {
// vars
$input = array('type' => 'text', 'name' => $field['name'], 'value' => '', 'disabled' => 'disabled', 'class' => 'acf-disabled');
// select other choice if value is not a valid choice
if ($checked === 'other') {
unset($input['disabled']);
$input['value'] = $field['value'];
}
// append other choice
$field['choices']['other'] = '</label><input type="text" ' . acf_esc_attr($input) . ' /><label>';
}
// bail early if no choices
if (empty($field['choices'])) {
return;
}
// hiden input
$e .= acf_get_hidden_input(array('name' => $field['name']));
// open
$e .= '<ul ' . acf_esc_attr($ul) . '>';
// foreach choices
foreach ($field['choices'] as $value => $label) {
// ensure value is a string
$value = strval($value);
$class = '';
// increase counter
$i++;
// vars
$atts = array('type' => 'radio', 'id' => $field['id'], 'name' => $field['name'], 'value' => $value);
// checked
if ($value === $checked) {
$atts['checked'] = 'checked';
$class = ' class="selected"';
}
// deisabled
if (isset($field['disabled']) && acf_in_array($value, $field['disabled'])) {
$atts['disabled'] = 'disabled';
}
// id (use crounter for each input)
if ($i > 1) {
$atts['id'] .= '-' . $value;
}
// append
$e .= '<li><label' . $class . '><input ' . acf_esc_attr($atts) . '/>' . $label . '</label></li>';
}
// close
$e .= '</ul>';
// return
echo $e;
}