Loading config/install/riddler.riddle.example.yml +1 −0 Original line number Diff line number Diff line id: 'example' question: 'Do you really hate Spam?' solution: 'Yes,Yes!,y,absolutely,yeah' hint: 'I think you do!' status: TRUE config/schema/riddler.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,6 @@ riddler.riddle.*: solution: type: text label: 'Solution' hint: type: label label: 'Hint' riddler.module +2 −3 Original line number Diff line number Diff line Loading @@ -49,10 +49,9 @@ function riddler_captcha($op, $captcha_type = '', $captcha_sid = NULL) { $result['form']['captcha_response'] = [ '#type' => 'textfield', '#title' => t('What\'s the correct answer?'), '#description' => t('Answer this question to verify that you are not a spam robot.'), '#title' => $riddleEntity->getQuestion(), '#description' => $riddleEntity->getHint(), '#weight' => 0, '#field_prefix' => $riddleEntity->getQuestion(), '#required' => TRUE, '#size' => 15, '#attributes' => ['autocomplete' => 'off'], Loading src/Entity/Riddle.php +20 −1 Original line number Diff line number Diff line Loading @@ -37,12 +37,14 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; * "id" = "id", * "question" = "question", * "solution" = "solution", * "uuid" = "uuid" * "uuid" = "uuid", * "hint" = "hint" * }, * config_export = { * "id", * "question", * "solution", * "hint" * } * ) */ Loading @@ -69,6 +71,13 @@ class Riddle extends ConfigEntityBase { */ protected $solution; /** * The question hint. * * @var string */ protected $hint; /** * The riddle status. * Loading Loading @@ -96,4 +105,14 @@ class Riddle extends ConfigEntityBase { return $this->solution; } /** * Get the question hint. * * @return string * The hint. */ public function getHint() { return $this->hint; } } src/Form/RiddleForm.php +8 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,14 @@ class RiddleForm extends EntityForm { '#required' => TRUE, ]; $form['hint'] = [ '#type' => 'textfield', '#title' => $this->t('Hint'), '#maxlength' => 255, '#default_value' => $this->entity->getHint() ?? '', '#description' => $this->t('An optional hint to help get the question right.'), ]; $form['id'] = [ '#type' => 'machine_name', '#default_value' => $this->entity->id(), Loading Loading
config/install/riddler.riddle.example.yml +1 −0 Original line number Diff line number Diff line id: 'example' question: 'Do you really hate Spam?' solution: 'Yes,Yes!,y,absolutely,yeah' hint: 'I think you do!' status: TRUE
config/schema/riddler.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,6 @@ riddler.riddle.*: solution: type: text label: 'Solution' hint: type: label label: 'Hint'
riddler.module +2 −3 Original line number Diff line number Diff line Loading @@ -49,10 +49,9 @@ function riddler_captcha($op, $captcha_type = '', $captcha_sid = NULL) { $result['form']['captcha_response'] = [ '#type' => 'textfield', '#title' => t('What\'s the correct answer?'), '#description' => t('Answer this question to verify that you are not a spam robot.'), '#title' => $riddleEntity->getQuestion(), '#description' => $riddleEntity->getHint(), '#weight' => 0, '#field_prefix' => $riddleEntity->getQuestion(), '#required' => TRUE, '#size' => 15, '#attributes' => ['autocomplete' => 'off'], Loading
src/Entity/Riddle.php +20 −1 Original line number Diff line number Diff line Loading @@ -37,12 +37,14 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; * "id" = "id", * "question" = "question", * "solution" = "solution", * "uuid" = "uuid" * "uuid" = "uuid", * "hint" = "hint" * }, * config_export = { * "id", * "question", * "solution", * "hint" * } * ) */ Loading @@ -69,6 +71,13 @@ class Riddle extends ConfigEntityBase { */ protected $solution; /** * The question hint. * * @var string */ protected $hint; /** * The riddle status. * Loading Loading @@ -96,4 +105,14 @@ class Riddle extends ConfigEntityBase { return $this->solution; } /** * Get the question hint. * * @return string * The hint. */ public function getHint() { return $this->hint; } }
src/Form/RiddleForm.php +8 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,14 @@ class RiddleForm extends EntityForm { '#required' => TRUE, ]; $form['hint'] = [ '#type' => 'textfield', '#title' => $this->t('Hint'), '#maxlength' => 255, '#default_value' => $this->entity->getHint() ?? '', '#description' => $this->t('An optional hint to help get the question right.'), ]; $form['id'] = [ '#type' => 'machine_name', '#default_value' => $this->entity->id(), Loading