Crazy talk. Parsing a form based on what button is pressed
For the community managed taxonomy node form user interface, I need either multiple forms one after another (probably best) or a crazy way to parse one form with multiple buttons that, by virtue of what button is pressed alone, do different things.
This test:
$form['randomness'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#name' => 'detail on the randomness',
);$text = "inthechaos";
$form['order'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#name' => $text,
);$form['nid'] = array(
'#type' => 'value',
'#value' => $edit['nid'],
);
$form['vid'] = array(
'#type' => 'value',
'#value' => $edit['vid'],
);
Shows up in the submitted form as (with the '#name', which is usually 'op', the main thing appearing in the post array) --
[randomness] => Array
(
[#type] => submit
[#value] => Save
[#name] => detail on the randomness
[#post] => Array
(
[tags] => boo
[detail_on_the_randomness] => Save
[form_token] => 0afeafec05789ecab8d592ad9b6eb277
[form_id] => cmt_terms_node_form
[preview] =>
)[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => randomness
)[#weight] => 0.002
[#processed] =>
[#description] =>
[#attributes] => Array
(
)[#required] =>
[#input] => 1
[#button_type] => submit
[#executes_submit_callback] => 1
[#id] => edit-randomness
[#sorted] => 1
)[order] => Array
(
[#type] => submit
[#value] => Submit
[#name] => inthechaos
[#post] => Array
(
[tags] => boo
[detail_on_the_randomness] => Save
[form_token] => 0afeafec05789ecab8d592ad9b6eb277
[form_id] => cmt_terms_node_form
[preview] =>
)[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => order
)[#weight] => 0.003
[#processed] =>
[#description] =>
[#attributes] => Array
(
)[#required] =>
[#input] => 1
[#button_type] => submit
[#executes_submit_callback] => 1
[#id] => edit-order
[#sorted] => 1
)
That plan would involve calling each form element's parent by what sort of submit I want, e.g. $form['endorse_placement']
and doing crazy stuff on the result to turn the array of variables in this into a bunch of strings with the variable names
Use the compact function
http://us.php.net/manual/en/function.compact.php
no, no, no. Multiple forms on a page.
We will not do any crazy php to parse variable name.
We may use PHP's variable function names capability.
http://php.mirrors.ilisys.com.au/manual/en/functions.variable-functions.php
For the community managed taxonomy node form user interface, I need either multiple forms one after another (probably best) or a crazy way to parse one form with multiple buttons that, by virtue of what button is pressed alone, do different things.
This test:
$form['randomness'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#name' => 'detail on the randomness',
);$text = "inthechaos";
$form['order'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#name' => $text,
);$form['nid'] = array(
'#type' => 'value',
'#value' => $edit['nid'],
);
$form['vid'] = array(
'#type' => 'value',
'#value' => $edit['vid'],
);
Shows up in the submitted form as (with the '#name', which is usually 'op', the main thing appearing in the post array) --
[randomness] => Array
(
[#type] => submit
[#value] => Save
[#name] => detail on the randomness
[#post] => Array
(
[tags] => boo
[detail_on_the_randomness] => Save
[form_token] => 0afeafec05789ecab8d592ad9b6eb277
[form_id] => cmt_terms_node_form
[preview] =>
)[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => randomness
)[#weight] => 0.002
[#processed] =>
[#description] =>
[#attributes] => Array
(
)[#required] =>
[#input] => 1
[#button_type] => submit
[#executes_submit_callback] => 1
[#id] => edit-randomness
[#sorted] => 1
)[order] => Array
(
[#type] => submit
[#value] => Submit
[#name] => inthechaos
[#post] => Array
(
[tags] => boo
[detail_on_the_randomness] => Save
[form_token] => 0afeafec05789ecab8d592ad9b6eb277
[form_id] => cmt_terms_node_form
[preview] =>
)[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => order
)[#weight] => 0.003
[#processed] =>
[#description] =>
[#attributes] => Array
(
)[#required] =>
[#input] => 1
[#button_type] => submit
[#executes_submit_callback] => 1
[#id] => edit-order
[#sorted] => 1
)
That plan would involve calling each form element's parent by what sort of submit I want, e.g. $form['endorse_placement']
and doing crazy stuff on the result to turn the array of variables in this into a bunch of strings with the variable names
Use the compact function
http://us.php.net/manual/en/function.compact.php
no, no, no. Multiple forms on a page.
We will not do any crazy php to parse variable name.
We may use PHP's variable function names capability.
http://php.mirrors.ilisys.com.au/manual/en/functions.variable-functions.php
Comments
Post new comment