base-function.php
3 years ago
function-hide.php
3 years ago
function-set-value.php
3 years ago
function-show.php
3 years ago
function-set-value.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Blocks\Conditional_Block\Functions; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Blocks\Conditional_Block\Condition_Item; |
| 8 | use Jet_Form_Builder\Presets\Types\Dynamic_Preset; |
| 9 | |
| 10 | class Function_Set_Value extends Base_Function { |
| 11 | |
| 12 | public function get_id(): string { |
| 13 | return 'set_value'; |
| 14 | } |
| 15 | |
| 16 | public function get_title(): string { |
| 17 | return __( 'Set value for this field if...', 'jet-form-builder' ); |
| 18 | } |
| 19 | |
| 20 | public function to_response( array $base, Condition_Item $item ): array { |
| 21 | $json = $item->base['set_value'] ?? ''; |
| 22 | $set_value = ( new Dynamic_Preset() )->parse_json( $json ); |
| 23 | |
| 24 | return parent::to_response( $base, $item ) + array( |
| 25 | 'set_value' => $set_value, |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | } |