Closed nilmerg closed 1 year ago
Can this also be based on the label, as with SubmitElement
? I don't like that the implementations differ so much. Also, if I understand it correctly, you would have to set different submit values when using multiple SubmitButtonElement
s.
Can this also be based on the label, as with SubmitElement? I don't like that the implementations differ so much.
If we do this, there needs to be an option like Zend's content
. Because the one advantage of <button>
is that it differentiates between value and label.
Also, if I understand it correctly, you would have to set different submit values when using multiple SubmitButtonElements.
Or a different name for each. Err, not or, you can't normally have multiple elements with the same name. You can only register one and just render the others, but I consider this a special use case which could even be adapted by a custom element type like a radio input, but that's not what this element is about.
$form->addElement('submitButton', 'foo', [
'label' => 'Foo' // Will also be the submitted value
]);
$form->addElement('submitButton', 'bar', [
'label' => 'bar',
'content' => new Icon('bar') // Required to still support non-string-labels
]);
/* sometime later */
$form->getPressedSubmitElement()->getValue() === 'bar';
/* or */
$form->getElement('bar')->hasBeenPressed();
$form->addElement('submitButton', 'abc', [
'label' => 'ABC'
]);
$form->addElement('submitButton', 'cba', [
'label' => new Icon('cba')
]);
/* sometime later */
$form->getPressedSubmitElement()->getName() === 'cba';
/* or */
$form->getElement('cba')->hasBeenPressed();
--
I personally like the submitValue as value approach better, because since I have to provide unique name anyway, I also check on the name and I am able to easily provide a non-string-label.
fixes #115