Hey guys,
I'm currently adding default values for all sorts of fields using the great hooks you provide for most input types. However I'm currently trying to limit the address 'province' dropdown to only 2 provinces (as this particular 'thing' is limited to those 2 provinces). I've looked through the core files and can't see any filters which would allow for that. I've tried using the gform_pre_render hook (which works great for normal dropdowns) and the gform_field_value_* hook without any success.
I can see that for an address the setup is slightly different (As you'd expect) as the $field has an [inputs] part of the array. I've tried doing something like $field['inputs'][3]['choices'] = array( 'text' => 'test', 'value' => 'testval' ) within the gform_pre_render hook but to no avail.
Am I missing something?
public function auto_populate_address_province( $form )
{
foreach( $form['fields'] as &$field )
{
if( $field['type'] != 'address' || strpos( $field['cssClass'], 'slide2-address' ) === false )
continue;
//gForms expects an array with 'text', 'value' and 'isSelected' as keys
$choices = array( array( 'text' => 'test', 'value' => 'value' ), array( 'text' => 'test2', 'value' => 'value2' ) );
$field['inputs'][3]['choices'] = $choices;
}
return $form;
}/* auto_populate_address_province() */