Ready to learn how forms are built or manipulated in Drupal using PHP code? Take your Drupal skills up to the next level by getting comfortable with the basic PHP needed to build and manipulate forms using the Form API (also known as FAPI).
What you will learn:
What form fields are possible using the Form API
How to build a new form from scratch that appears at a custom URL
How to override (manipulate) an existing form
How to make fields disabled, appear in a different order, or save their data elsewhere
How to debug a form
Basic info on creating CUSTOM form fields & items
Form API info good for both Drupal 7 & 6
NOTE: To enjoy this session fully you should be comfortable with HTML & CSS, and have some basic comfort or understanding of Arrays and/or PHP.
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
Drupal Form API 101 (PHP) - DrupalCamp LA 2012
1. Form API 101
Intro to building Forms in Drupal using PHP
!
!
presented by Chris Charlton
http://xtnd.us
2. Drupal uses PHP Arrays for forms
• Easy to Add, Remove, or Alter:
• Form fields & their attributes
• Validation & Submit handling
• Form tag & attributes
• Write less code
• Reduces markup errors
3. Form Field Types
• Text input
• File input/upload
• Select Lists/Menu/Dropdowns
• Checkboxes, Radiobuttons
• Lots of types, or make your own!
4. Before we talk Drupal...
• <form> HTML tag
• PHP code summary
• Basics
• Arrays
7. PHP Basics
Strings - “this is a string”
Numbers - 1234567890
Variables - $long_var_name = 123;
Functions - hook_form()
8. PHP Arrays
<?php
// Declare new basic array of numbers up to ten
$array_of_numbers = array(0, 1, 2, 3, 4, 5, 6, 7, 8);
$array_of_numbers[] = 9; // Add an array item
$array_of_numbers[] = 10; // Add another item
//Declare new basic array of strings
$array_of_strings = array(‘A’, ‘b’, ‘C’, ‘d’, ‘E’);
!
9. Mixed Key PHP Array
<?php
// Declare multidimensional array with mixed keys
$mixed_array = array(
0 => ‘index zero has this string value’,
1 => ‘index one has this similar string value’,
‘two’ => ‘index two has a string key’,
‘three’ => ‘index three also has a string key’,
4 => ‘index four is a numeric key like index 0 & 1’
);
!
10. Multidimensional PHP Array
<?php
// Declare multidimensional array with mixed keys
$multidim_array = array(
0 => array(
“person0” => “Jay”,
“person1” => “Silent Bob”,
“person2” => “Chris”
),
1 => ‘index one has this similar string value’,
‘two’ => ‘index two has a string key’,
‘three’ => ‘index three also has a string key’,
4 => ‘index four is a numeric key like index 0 & 1’
);