get_field_meta()->is_multiple() ?
'choice_item' :
$field_id;
$markup_field_data->set_is_with_field_wrapper(
$markup_field_data->get_field_meta()->is_multiple() ||
$markup_field_data->is_with_field_wrapper()
);
printf(
'
',
esc_html(
$this->get_field_class( 'choice', $markup_field_data )
)
);
$token_factory = $markup_field_data->get_token_factory();
$token_factory->format()
->new_line();
$markup_field_data->increment_and_print_tabs();
$var = $token_factory
->variable( $twig_name )
->add_item_path( 'title' );
$token_factory
->to_echo( $var )
->print();
$token_factory->format()
->new_line();
$markup_field_data->decrement_and_print_tabs();
echo '
';
}
/**
* @return array
*/
protected function get_item_template_args( Variable_Field_Data $variable_field_data ): array {
$value = is_string( $variable_field_data->get_value() ) ?
$variable_field_data->get_value() :
'';
return array(
'title' => $variable_field_data->get_field_meta()->get_choices()[ $value ] ?? '',
'value' => $value,
);
}
/**
* @return array
*/
public function get_template_variables( Variable_Field_Data $variable_field_data ): array {
return array_merge(
parent::get_template_variables( $variable_field_data ),
array(
'choices' => $variable_field_data->get_field_meta()->get_choices(),
)
);
}
/**
* @return array
*/
protected function get_validation_item_template_args( Variable_Field_Data $variable_field_data ): array {
return array(
'title' => 'Option',
'value' => 'option',
);
}
/**
* @return array
*/
public function get_validation_template_variables( Variable_Field_Data $variable_field_data ): array {
return array_merge(
parent::get_validation_template_variables( $variable_field_data ),
array(
'choices' => array(
'option' => 'Option',
),
)
);
}
}