0

Sorry if this an extremely newby question but I am a beginner and still trying to learn how to navigate through the site. Anyway, I am trying to create a form uploader. For example, I want someone to go to their profile page, hit upload, and then a form with 5 or so fields come up where they can fill things out and then upload it to the main content page.

Here is a use case that I am thinking of: I have a picture that my little sister drew, and I want her to add a description, the title of her picture and date it. When I hit upload there will be a upload image field and three text fields for the title, date and description. Then I want it to display on the homepage.

Sorry if that was a really tedious description for a really simple function. I appreciate all the help though! Thanks in advance for all your time and help.

Pete

1 Answer 1

1

The simplist way is to give your users permission to add a node. This would be done through admin/people/permissions.

To get a node to automatically appear on the front page, the publishing options for the content type need to default to 'Promoted to front page'. Set this up when you are creating your content type.

If you want to create a custom form, the method (perhaps not for newbies) is:

(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).

(7) Add a validation function, if needed.

(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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.