Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Monday, April 9, 2012

How to display something onscreen - using menu & form

variable_set(), variable_get() and system_setting_form()

Some explanations on the use of variable_set(), variable_get() and system_setting_form().



You can get the complete info here.

mental note on drupal form coding

This is a mental note for me to do. I need to make a summary of what are the things that i've learnt when developing form in drupal. Until now, i can only summarise that there are too many complex commands that require me to understand. So it's better if i can summarise them all in a single illustration so that it's easier to mentally digest.
.

Friday, April 6, 2012

Writing drupal module - Form creation

After 3 days have passed, i finally able to continue my drupal module coding. Today, what i did is creating form elements inside drupal site.

The order of creating form in drupal is like this:

  1. use command 'page callback' where its value is the key function in drupal called drupal_get_form()
  2. use command 'page arguments' whose value is an array that contains a value referring to a name of function (must use underscore in a single word, eg: nama_saya_shahrul. this value - nama_saya_shahrul will be passed to key function drupal_get_form() for drupal to process the form.
  3. Create function nama_saya_shahrul($form, &$form_state), this is just an example.
  4. use variable array that has the followings (make sure you never miss out the hash)


    • #type
    • #title
    • #description
    • #default_value
    • #size
    • #maxlength
    • #required

  5. Need to use another drupal-specific function called variable_get('nama_textfield',default-value). I think variable_get() is similar to session() or assigning value to hidden form field where we can retrieve them later on.
  6. last but not least is using system_settings_form($form) function.

And the following videolog is the output from the new codes