By maori on
hi guys
i'am working on a custom module that i want to have a form in it that writes the inputed data into the database
if i understand correctly i can have a tpl file that would display the layout of the form is that correct ?
and if so how do i implement this.
Actually advise on the complete setup would be helpfull if some kind soul would point me in the right direction
complete n00b to drupal
TIA
Comments
_
You need to use the Form API - http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
heya thanks for that :) can
heya
thanks for that :)
can i make the form look the way i want to ? as the example there i would imagine are side by side each other or under
which is where the tpl file come's into play correct ?
TIA
_
No, not at all.
The template file actually creates the final page content, but will define styles for that content that is defined in stylesheets, i.e. CSS files.
See http://drupal.org/project/Themes for general theming stuff and http://drupal.org/phptemplate for template file documentation.
Actually, forms can be
Actually, forms can be templated just like outputted content. For example, to theme the contact form:
And then the template works like this:
contact-page.tpl.php
Contact me to contract me for D7 -> D10/11 migrations.
Just use
Just use http://drupal.org/project/webform?
hiya I did have a look at
hiya
I did have a look at that but i dont think it will do what i need as the info submited is stored in to diffrent custom tables on the database
Here is an
Here is an example:
http://11heavens.com/theming-the-contact-form-in-Drupal-6
Contact me to contract me for D7 -> D10/11 migrations.
hiya Thanks everyone this
hiya
Thanks everyone this definatly points me in the right direction :D
hi guys ok i tried al the
hi guys
ok i tried al the above but some how all i get is a blank page :(
in my form i have
then in the tpl.php file i have
what have i messed up ? i have cleared the cache etc,etc
TIA
_
If you're seeing a completely blank page, a.k.a. the White Screen of Death, there's a PHP error somewhere - check the recent log entries and your Apache error log.
I notice you've got 'mylog' and MyLog as prefixes, which may have something to do with it.
heya yeah its the white page
heya
yeah its the white page of death nothing in the drupal logs that i can see
_
Not the Drupal logs, the Apache error logs...
okidoki i'am getting a bit
okidoki
i'am getting a bit closer
and it now shows the tpl.php file with the content and content2 ok but not the textfield :( what am i missing here
TIA
Your preprocess function
Your preprocess function should be called template_preprocess_mylog. Template functions are only prefixed by the module name when they are changing other module's templates.
I don't know if that will solve your problem, but it's somewhere to start.
Contact me to contract me for D7 -> D10/11 migrations.
hi ya ok changed the code to
hi ya
ok changed the code to
and the output to the window is
so its not showing the textfield in the tpl.php file
i know it's me but i bee blown as to known the reason :(
okidoki :P addedd function
okidoki :P
addedd
and the textfield now shows but dosnt show my username automatically ?
in the tpl file i have
?>
Preprocessing functions are
Preprocessing functions are always passed on argument by reference. Generally it's called 'vars'. So your preprocess function declaration will look like this:
function template_preprocess_mylog(&$vars)$vars is a keyed array. The keys of the array become the variables that are available in your template file. For example:
The key of the array is 'greeting', so now, in the template file, you can do this:
<h1><?php print $greeting; ?></h1>And this will print out the following to the source:
<h1>Hello, and welcome to this site</h1>And will print this to the screen:
Hello, and welcome to this siteContact me to contract me for D7 -> D10/11 migrations.
hi jay I tried what you
hi jay
I tried what you posted above and it does work as it should but the textfield still dosnt show the username :( here the full code of my module
and in the tpl file i have
so what i'am after is the #default_value' for the textfield to be filled in by defualt here it will be the logged in user it works if i dont use the tpl file way so i'am at a loss to understand why
thanks for all your help
well been at it for a few
well been at it for a few more hours today and still cant seem to work this one out :(
i bet its one of those that i been making it harder than it is i'am sure but cant belive it is this hard to get a form to look the way i want to rather than the elememnts staked below each other :(
finnally :P ok so far so
finnally :P
ok so far so good posting the code here in case someone else comes across the problems i have been having
the only problem i have is the submit function dosnt seem to work :( click the button and the page refreshes but dosnt give the info it should