[TASK] Formstyle

This commit is contained in:
Christian Seyfferth 2020-05-20 17:34:25 +02:00
parent 327b33a92e
commit f5f43b2173
3 changed files with 56 additions and 51 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* p01-contact - A simple contact forms manager. * p01-contact - A simple contact forms manager.
* *
@ -214,18 +215,13 @@ class P01contactField
$placeholder = $this->placeholder ? ' placeholder="' . $this->placeholder . '"' : ''; $placeholder = $this->placeholder ? ' placeholder="' . $this->placeholder . '"' : '';
$is_single_option = is_array($this->value) && 1 == count($this->value) ? 'inline' : ''; $is_single_option = is_array($this->value) && 1 == count($this->value) ? 'inline' : '';
$html = "<div class=\"row field {$is_single_option} {$type} {$orig} {$required}\">"; $html = "<div class=\"col s12 input-field {$is_single_option} {$type} {$orig} {$required}\">";
$html .= '<div class="col-sm-12 col-md-3">';
if ('' === $is_single_option) {
$html .= $this->htmlLabel($id);
}
$html .= '</div>';
$html .= '<div class="col-sm-12 col-md">';
switch ($type) { switch ($type) {
case 'textarea': case 'textarea':
$html .= '<textarea id="' . $id . '" rows="10" '; $html .= '<textarea id="' . $id . '" rows="10" ';
$html .= 'class="materialize-textarea" ';
$html .= 'name="' . $name . '"' . $disabled . $required . $placeholder; $html .= 'name="' . $name . '"' . $disabled . $required . $placeholder;
$html .= '>' . $value . '</textarea>'; $html .= '>' . $value . '</textarea>';
@ -248,11 +244,11 @@ class P01contactField
foreach ($this->value as $i => $v) { foreach ($this->value as $i => $v) {
$selected = $this->isSelected($i) ? ' checked' : ''; $selected = $this->isSelected($i) ? ' checked' : '';
$v = !empty($v) ? $v : 'Default'; $v = !empty($v) ? $v : 'Default';
$html .= '<label class="option col-sm-12">'; $html .= '<p><label class="option col s12">';
$html .= "<input id=\"{$id}_option{$i}\""; $html .= "<input id=\"{$id}_option{$i}\"";
$html .= " type=\"{$type}\" class=\"{$type}\" name=\"{$name}\""; $html .= " type=\"{$type}\" class=\"{$type}\" name=\"{$name}\"";
$html .= " value=\"{$i}\"{$disabled}{$required}{$selected} />{$v}"; $html .= " value=\"{$i}\"{$disabled}{$required}{$selected} /><span>{$v}</span>";
$html .= '</label>'; $html .= '</label></p>';
} }
$html .= '</div>'; $html .= '</div>';
@ -275,8 +271,9 @@ class P01contactField
break; break;
} }
if ('' === $is_single_option) {
$html .= '</div>'; $html .= $this->htmlLabel($id);
}
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
@ -371,7 +368,7 @@ class P01contactField
*/ */
private function htmlLabel($for) private function htmlLabel($for)
{ {
$html .= '<label for="'.$for.'" class="doc">'; $html .= '<label for="' . $for . '" class="doc validate">';
if ($this->title) { if ($this->title) {
$html .= $this->title; $html .= $this->title;
} else { } else {

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* p01-contact - A simple contact forms manager. * p01-contact - A simple contact forms manager.
* *
@ -88,8 +89,10 @@ class P01contactForm
*/ */
public function post() public function post()
{ {
if (empty($_POST['p01-contact_form']) if (
|| $_POST['p01-contact_form']['id'] != $this->id) { empty($_POST['p01-contact_form'])
|| $_POST['p01-contact_form']['id'] != $this->id
) {
return; return;
} }
@ -163,6 +166,7 @@ class P01contactForm
$html .= '<form action="' . PAGEURL . '#p01-contact' . $this->id . '" autocomplete="off" '; $html .= '<form action="' . PAGEURL . '#p01-contact' . $this->id . '" autocomplete="off" ';
$html .= 'id="p01-contact' . $this->id . '" class="p01-contact" method="post">'; $html .= 'id="p01-contact' . $this->id . '" class="p01-contact" method="post">';
$html .= "<div class=\"row\">";
if ($this->status) { if ($this->status) {
$html .= $this->htmlStatus(); $html .= $this->htmlStatus();
} }
@ -177,6 +181,8 @@ class P01contactForm
$html .= '<input name="p01-contact_form[token]" type="hidden" value="' . $this->getToken() . '" />'; $html .= '<input name="p01-contact_form[token]" type="hidden" value="' . $this->getToken() . '" />';
$html .= '<input class="submit" type="submit" value="' . $this->lang('send') . '" /></div>'; $html .= '<input class="submit" type="submit" value="' . $this->lang('send') . '" /></div>';
} }
$html .= '</div>';
$html .= '</form>'; $html .= '</form>';
$html .= '</div>'; $html .= '</div>';

View File

@ -1,3 +1,4 @@
/*
.p01-contact * { .p01-contact * {
box-sizing: border-box; box-sizing: border-box;
} }
@ -98,3 +99,4 @@ textarea:invalid {
border-color: #ebccd1; border-color: #ebccd1;
} }
*/