From 1daa6ce7e2be79ef29fe190c4f91e10e1a1b35a1 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Thu, 2 Apr 2020 22:22:24 +0200 Subject: [PATCH] WIP #3445 @10 --- wp-content/mu-plugins/cube/src/Forms/Base.php | 57 ++++++-- .../cube/src/Forms/Consultation.php | 29 +++- .../images/consultation-body-outline.svg | 6 + .../resources/assets/images/imagery-cd.svg | 12 ++ .../resources/assets/images/imagery-phone.svg | 24 ++++ .../resources/assets/images/imagery-post.svg | 19 +++ .../resources/assets/images/imagery-web.svg | 18 +++ .../resources/assets/scripts/consultation.js | 29 ++++ .../CCV/resources/assets/styles/app.styl | 2 +- .../assets/styles/common/spacing.styl | 2 + .../assets/styles/components/forms.styl | 18 +-- .../assets/styles/pages/consultation.styl | 11 ++ .../views/forms/consultation.blade.php | 132 +++++++++++++++--- wp-content/themes/CCV/webpack.mix.js | 1 + 14 files changed, 317 insertions(+), 43 deletions(-) create mode 100644 wp-content/themes/CCV/resources/assets/images/consultation-body-outline.svg create mode 100644 wp-content/themes/CCV/resources/assets/images/imagery-cd.svg create mode 100644 wp-content/themes/CCV/resources/assets/images/imagery-phone.svg create mode 100644 wp-content/themes/CCV/resources/assets/images/imagery-post.svg create mode 100644 wp-content/themes/CCV/resources/assets/images/imagery-web.svg create mode 100644 wp-content/themes/CCV/resources/assets/scripts/consultation.js create mode 100644 wp-content/themes/CCV/resources/assets/styles/pages/consultation.styl diff --git a/wp-content/mu-plugins/cube/src/Forms/Base.php b/wp-content/mu-plugins/cube/src/Forms/Base.php index f01488c..e1aebef 100644 --- a/wp-content/mu-plugins/cube/src/Forms/Base.php +++ b/wp-content/mu-plugins/cube/src/Forms/Base.php @@ -16,6 +16,19 @@ class Base const TEXTAREA = 'textarea'; + public function __construct() { + $this->register_scripts(); + $this->register_fields(); + } + + public function register_scripts() { + + } + + public function register_fields() { + + } + /** * Output field HTML * @param $name @@ -40,10 +53,7 @@ class Base $settings = array_merge($default_settings, $settings); $res = ''; - - if ($settings['show_title']) { - $res .= '
'. $field['title'] .'
'; - } + $res .= $this->title($name, $settings); // Special input styling for checkbox / radio fields if (in_array($field['type'], [self::BINARY, self::CHECKBOX, self::RADIO])) { @@ -63,6 +73,24 @@ class Base return '
'. $res .'
'; } + /** + * Generate field title + * @param $name + * @param $settings + * @return bool|string + */ + public function title($name, $settings = []) { + + if (!isset($settings['show_title']) || !$settings['show_title']) return ''; + + $title_class = $settings['title_class'] ?? ''; + + $field = $this->getField($name); + if (!$field) return false; + + return '
'. $field['title'] .'
'; + } + /** * Generate a radio or checkbox input * @param $name @@ -82,7 +110,7 @@ class Base $res .= '