options array for select field
-
hi!it’s some going wrong with “adverts_field_select” field
documentation say that in “options” i must type like thisarray( array( "value" => 1, "text" => "One", "depth" => 1 ), array( "value" => 5, "text" => "Five", "depth" => 1 ), // more options here ... );
but i have dinamical array
foreach ($countries_array as $val) { $prepeared_countries[]= array( "value" => "1", "text" => "1"); }
,for example let it be like this
$a=array(array( "value" => "1", "text" => "One"));
when i place a variable into the option
$form["field"][] = array( "name" => "country", "type" => "adverts_field_select", "order" => 4, "label" => __("Category", "adverts"), "max_choices" => 1, "options" => $a, "validator" => array( array( "name" => "max_choices", "params" => array( "max_choices" => 1 ) ) ) );
it’s give me the error
Fatal error: You need to specify options source for field [country]. in /home/****/*******.com/www/wp-content/plugins/wpadverts/includes/functions.php on line 1365
if i doing like this
$form["field"][] = array( "name" => "country", "type" => "adverts_field_select", "order" => 4, "label" => __("Category", "adverts"), "max_choices" => 1, "options" => array($a), "validator" => array( array( "name" => "max_choices", "params" => array( "max_choices" => 1 ) ) ) );
i’ll get just empty select field,without options
but if i type just like this$form["field"][] = array( "name" => "country", "type" => "adverts_field_select", "order" => 4, "label" => __("Category", "adverts"), "max_choices" => 1, "options" => array( array( "value" => 1, "text" => "One", "depth" => 1 ), array( "value" => 5, "text" => "Five", "depth" => 1 ),), "validator" => array( array( "name" => "max_choices", "params" => array( "max_choices" => 1 ) ) ) );
it give me the two options in select field.what is going wrong with array in variable?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘options array for select field’ is closed to new replies.