Skip to content

Commit

Permalink
enhanced button element/updated no to display submit with empty label
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasjonas committed Feb 21, 2018
1 parent 816bd27 commit 7483983
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
4 changes: 1 addition & 3 deletions Elements/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public function __toString()
$helpMessage = $this->htmlHelpMessage();

return "<p {$wrapperAttributes}>" .
"<label>" .
"<button name=\"{$this->name}\" type=\"submit\"{$inputAttributes} value=\"{$value}\">{$label}</button>" .
"</label>" .
"<button name=\"{$this->name}\" type=\"submit\"{$inputAttributes} value=\"{$value}\">{$label}</button>" .
$errorMessage .
$helpMessage .
"</p>\n";
Expand Down
30 changes: 16 additions & 14 deletions HtmlForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ protected function setDefaults()
$this->defaults['successURL'] = $_SERVER['REQUEST_URI'];
$this->defaults['cancelURL'] = $_SERVER['REQUEST_URI'];
$this->defaults['validator'] = null;
$this->defaults['ttl'] = 30 * 60; // 30 minutes
$this->defaults['ttl'] = 60 * 60; // 60 minutes
$this->defaults['jsValidation'] = 'blur';
$this->defaults['jsAutosave'] = 'false';
}
Expand Down Expand Up @@ -1000,14 +1000,17 @@ protected function htmlDataAttributes()
**/
public function __toString()
{
$renderedElements = '';
$label = $this->htmlLabel();
$cancellabel = $this->htmlCancelLabel();
$backlabel = $this->htmlBackLabel();
$class = $this->htmlClass();
$method = $this->htmlMethod();
$submitURL = $this->htmlSubmitURL();
$dataAttr = $this->htmlDataAttributes();
$renderedElements = '';
$submit = '';
$cancel = '';
$back = '';
$label = $this->htmlLabel();
$cancellabel = $this->htmlCancelLabel();
$backlabel = $this->htmlBackLabel();
$class = $this->htmlClass();
$method = $this->htmlMethod();
$submitURL = $this->htmlSubmitURL();
$dataAttr = $this->htmlDataAttributes();

foreach ($this->elementsAndHtml as $element) {
// leave out inactive step elements
Expand All @@ -1020,19 +1023,18 @@ public function __toString()

if (!is_null($this->cancelLabel)) {
$cancel = "<p id=\"{$this->name}-cancel\" class=\"cancel\"><input type=\"submit\" name=\"formSubmit\" value=\"{$cancellabel}\"></p>\n";
} else {
$cancel = "";
}
if (!is_null($this->backLabel) && $this->currentStepId > 0) {
$back = "<p id=\"{$this->name}-back\" class=\"back\"><input type=\"submit\" name=\"formSubmit\" value=\"{$backlabel}\"></p>\n";
} else {
$back = "";
}
if (!empty($this->label)) {
$submit = "<p id=\"{$this->name}-submit\" class=\"submit\"><input type=\"submit\" name=\"formSubmit\" value=\"{$label}\"></p>\n";
}


return "<form id=\"{$this->name}\" name=\"{$this->name}\" class=\"depage-form {$class}\" method=\"{$method}\" action=\"{$submitURL}\"{$dataAttr} enctype=\"multipart/form-data\">" . "\n" .
$renderedElements .
"<p id=\"{$this->name}-submit\" class=\"submit\"><input type=\"submit\" name=\"formSubmit\" value=\"{$label}\"></p>" . "\n" .
$submit .
$cancel .
$back .
"</form>";
Expand Down
9 changes: 9 additions & 0 deletions lib/sass/depage-forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
width: 100%;
}
input,
button,
select,
textarea,
.textarea,
Expand Down Expand Up @@ -139,6 +140,7 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
padding-right: 0;
}
input,
button,
select,
textarea,
.textarea,
Expand Down Expand Up @@ -181,6 +183,7 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
line-height: 1.8em;
}
input,
button,
select,
textarea,
.textarea,
Expand All @@ -193,9 +196,11 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
.input-boolean,
.input-single,
.input-multiple,
.input-button,
.back,
.cancel,
.submit {
button,
input {
width: auto;
}
Expand All @@ -216,6 +221,7 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
// }}}
// {{{ input states
input,
button,
select,
textarea,
.textarea {
Expand Down Expand Up @@ -257,6 +263,7 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
}
.error {
input,
button,
select,
textarea,
.textarea {
Expand All @@ -276,9 +283,11 @@ $depageFormRadiobuttonHeight: $depageFormRadiobuttonSize !default;
.error .depage-label {
color: $depageFormLabelErrorColor;
}
.input-button button,
.submit input {
background: #cccccc;
}
.input-button.error button,
.submit.error input {
border: 1px solid #dddddd;
color: #999999;
Expand Down

0 comments on commit 7483983

Please sign in to comment.