Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. function zimo_schema() {
  2. $schema['zimo'] = array(
  3. 'description' => 'Stores example person entries for demonstration purposes.',
  4. 'fields' => array(
  5. 'pid' => array(
  6. 'type' => 'serial',
  7. 'not null' => TRUE,
  8. 'description' => 'Primary Key: Unique person ID.',
  9. ),
  10.  
  11. 'name' => array(
  12. 'type' => 'varchar',
  13. 'length' => 255,
  14.  
  15. ),
  16.  
  17. 'paiddate' => array(
  18. 'type' => 'date',
  19.  
  20. ),
  21. 'amount' => array(
  22. 'type' => 'bigint',
  23.  
  24. ),
  25. ),
  26. 'primary key' => array('pid'),
  27.  
  28. );
  29.  
  30. return $schema;
  31. }
  32.  
  33. namespace DrupalzimoForm;
  34.  
  35. use DrupalCoreFormFormBase;
  36. use DrupalCoreFormFormStateInterface;
  37. use DrupalzimoZimoStorage;
  38.  
  39. /**
  40. * Simple form to add an entry, with all the interesting fields.
  41. */
  42. class ZimoAddForm extends FormBase {
  43.  
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getFormId() {
  48. return 'zimo_add_form';
  49. }
  50.  
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function buildForm(array $form, FormStateInterface $form_state) {
  55. $form = array();
  56.  
  57. $form['message'] = array(
  58. '#markup' => $this->t('Add an entry to the Zimo Database table.'),
  59. );
  60.  
  61. $form['add'] = array(
  62. '#type' => 'fieldset',
  63. '#title' => t('Add a person entry'),
  64. );
  65. $form['add']['name'] = array(
  66. '#type' => 'textfield',
  67. '#title' => t('Name'),
  68. '#size' => 15,
  69. );
  70. $form['add']['paiddate'] = array(
  71. '#type' => 'date',
  72. '#title' => t('Paid Date'),
  73. );
  74. $form['add']['amount'] = array(
  75. '#type' => 'textfield',
  76. '#title' => t('Paid Amount')
  77. );
  78. $form['add']['submit'] = array(
  79. '#type' => 'submit',
  80. '#value' => t('Add'),
  81. );
  82.  
  83. return $form;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement