Pass $parameters to add_options callback
f.e.:
->add_options( array( $this, 'get_custom_taxonomy_for_select' ), 'custom_tax' )
or even
->add_options( array( $this, 'get_custom_taxonomy_for_select' ), array( 'key' => 'value' ) )
DRY salt on this would be delicious!
Thanks for the great work!
I think this goes beyond the scope of what an ->add_options() method should do.
I'd suggest you use an anonymous function instead:
->add_options( function() use ( $your_object ) {
return $your_object->get_custom_taxonomy_for_select( array( 'key' => 'value' ) );
} )
Tried that, the ! is_callable ( $options ) here blocks an anonymous call.
I tested on PHP 5.3 and PHP 7 just to make sure and is_callable() returns true for anonymous functions as expected:
var_dump( is_callable( function() {} ) );
I also tested this and it works correctly as well:
Field::make( 'select', 'crb_closure_select' )
->add_options( function() {
return array( 'foo'=>'Foo' );
} ),
Your right, my bad, had v1.5 on this install, sorry for inconvenience, thank you.
No worries : )