How can I create a customised add/node form in D7?
I am not talking about a form for gathering information that is not content for the site, like an event registration form. I'm talking about the node/add form where you create content for your site.
What I want to replicate is just some simple html tables, arranged together, and some css to make it look good. Lots of boxes in which to insert numbers, mainly, a few drop-downs and text fields too. Imagine you navigate to node/add/scorecard and something like this appears:
Thanks.
SOLUTION
This is the solution I have arrived at:
(1) Create a module (.INFO and .MODULE files).
(2) Implement hook_menu (in your new module) to create a url and page where the form is to reside.
(3) Add a function to render the HTML of the form using drupal_get_form.
(4) Add a form builder function and construct your form using an array called $form (see form API for details).
(5) Add a submit button at the end of your form.
(6) To make the form look the way you want it to there are several methods: (i) create a theme function to add to the elements of $form; (ii) use #prefix and #suffix properties to add additional HTML and CSS ids/classes to the rendered form; (iii) manipulate the many ids/classes, rendered by drupal_get_form, with CSS; (iv) use the #markup properties to add additional HTML and CSS ids/classes to the rendered form (not recommended). I used a combination of (ii) and (iii). I could not work out how to do (i) but it is probably the 'most correct' method.
(7) Add a validation function.
(8) Add a submit function using node_save (for nodes) and drupal_write_record (for fields) to insert your form values into the relevant database tables: node, field_data_field_my_field etc.