Hello Drupalites,
I am tryign to figure this out.
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
If I try and use CSS to access them [perhaps setting display:non for non-tech savy web admins]
Then this works, UNTIL something else changes on the page, and then the numbers all change... SO, I need to find a way to give these random place holding id's actual ID's that relate to the content inside of them [authored by, published, file upload etc.]
I found the hook:
<?php /* * Theming the node form */ function phptemplate_node_form($form) { $output = "\n<div class="node-form">\n";
// Admin form fields and submit buttons must be rendered first, because // they need to go to the bottom of the form, and so should not be part of // the catch-all call to drupal_render(). $admin = '';
$buttons = drupal_render($form['buttons']);
// Everything else gets rendered here, and is displayed before the admin form // field and the submit buttons. $output .= " <div class="standard">\n"; $output .= drupal_render($form); $output .= " </div>\n";
if (!empty($admin)) { $output .= " <div class="admin">\n"; $output .= $admin; $output .= " </div>\n"; } $output .= $buttons; $output .= "</div>\n";
return $output; } ?>
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
Also, the function:
drupal_render()
Doesn't really give me much control over how to theme the sub-parts of the form...
Can anyone help me to please give real class and/or id names to the elements of the form?
Thanks!
Sebastian
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
These are inserted by the devel_themer module and should not be relied upon
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
The call to drupal_render($form) actually renders the hidden elements such as form id and build id which are needed to determine if the form was submitted by the Form API. If these aren't found, the Form API thinks it wasn't submitted and hence no submit function is called and no data is saved. You need to examine the $form variable and unset (using the unset function) any array members (form elements) you don't want then add a final drupal_render($form) to the end of your output and thiss will add all the hidden stuff (and anything else that still yet to be rendered). I'm assuming you don't have a module here? Otherwise you could do the unsetting in hook_form_alter.
Hi Thanks Lee, others,
My ideal solution would be if the form elements had id or class names, that were unique, so that I could simply hide [display:none] the form elements that I don't feel like the less-tech savvy content admins need to see.
My back-up solution was turning them off as a function, as part of the drupal_render function.
This is for the node creation, of several node types; but right now I am just trying the basic: node->create->page type.
Couple of questions:
1. is there a way to inject class and/or node ID's to the basic node_edit form? I would want the title to always have something like "id="node_title" on ALL of my node edit forms; whether it is for adding a 'page' type, or a new type not yet imagined but latter added. [that way if I am always hiding the 'publishing options' section, for a particular user, it would be hidden site-wide on all forms]
2. if it is NOT possible to do the above, then my backup is to use drupal_render(), as described below. Am I correct that I would just use:
unset($form['name_of_element']); drupal_render($form);
?
3. If there is anyway I could take my work [above] and make it into a module for others to benefit from this change, I would love to contribute this to the drupal community. As I think I must not be the only person who wants to style specific elements on the node-creation page, and right now there is simply no way to target these fields in CSS...
I've never contributed before though, and still learning, so not sure if whatever changes I make will be compatible as a "module"
Thank you so much for your help!!
Sebastian.
Lee Rowlands wrote:
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
These are inserted by the devel_themer module and should not be relied upon
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
The call to drupal_render($form) actually renders the hidden elements such as form id and build id which are needed to determine if the form was submitted by the Form API. If these aren't found, the Form API thinks it wasn't submitted and hence no submit function is called and no data is saved. You need to examine the $form variable and unset (using the unset function) any array members (form elements) you don't want then add a final drupal_render($form) to the end of your output and thiss will add all the hidden stuff (and anything else that still yet to be rendered). I'm assuming you don't have a module here? Otherwise you could do the unsetting in hook_form_alter.
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
What you could do is create overrides for each form element type, adding an id or class based on the name or some other attribute of the form element. I've done this to style specific form elements in forms. That might be simpler than unsetting properties in the form array, and you could do it all from within your template rather than having to create a whole module. Have a look at the theme functions in the API documentation to see how you can do this.
sebastian wrote:
Hi Thanks Lee, others,
My ideal solution would be if the form elements had id or class names, that were unique, so that I could simply hide [display:none] the form elements that I don't feel like the less-tech savvy content admins need to see.
My back-up solution was turning them off as a function, as part of the drupal_render function.
This is for the node creation, of several node types; but right now I am just trying the basic: node->create->page type.
Couple of questions:
- is there a way to inject class and/or node ID's to the basic
node_edit form? I would want the title to always have something like "id="node_title" on ALL of my node edit forms; whether it is for adding a 'page' type, or a new type not yet imagined but latter added. [that way if I am always hiding the 'publishing options' section, for a particular user, it would be hidden site-wide on all forms]
- if it is NOT possible to do the above, then my backup is to use
drupal_render(), as described below. Am I correct that I would just use:
unset($form['name_of_element']); drupal_render($form);
?
- If there is anyway I could take my work [above] and make it into a
module for others to benefit from this change, I would love to contribute this to the drupal community. As I think I must not be the only person who wants to style specific elements on the node-creation page, and right now there is simply no way to target these fields in CSS...
I've never contributed before though, and still learning, so not sure if whatever changes I make will be compatible as a "module"
Thank you so much for your help!!
Sebastian.
Lee Rowlands wrote:
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
These are inserted by the devel_themer module and should not be relied upon
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
The call to drupal_render($form) actually renders the hidden elements such as form id and build id which are needed to determine if the form was submitted by the Form API. If these aren't found, the Form API thinks it wasn't submitted and hence no submit function is called and no data is saved. You need to examine the $form variable and unset (using the unset function) any array members (form elements) you don't want then add a final drupal_render($form) to the end of your output and thiss will add all the hidden stuff (and anything else that still yet to be rendered). I'm assuming you don't have a module here? Otherwise you could do the unsetting in hook_form_alter.
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
Hello comrades,
So I wasn't sure how to reference specific fields when most of the "standard" fields only have an id or class with something ultra generic like: "collapse-processed" or "filefield" ; which all the other fields also say...
So instead I wrote a function which finally achieved what I wanted: I'd be curious if this is not the best way to approach this though? as in future projects I want to repeat this again as it really does provide for a MUCH cleaner interface to just turn completely OFF anything that I don't think a user needs 99% of the time. The only thing missing here right now, is a user (role) check to toggle whether they are shown or not [I still want to see them, for odd occasions, but the 'client' doesn't need to] I use "node_type to actually figure out which node is in question as otherwise i can't do very good specific theming! I finally figured out today how to traverse the $form Array; which is a big help... ;)
Code follows:
function phptemplate_node_form($form) { $output = "\n<div class="node-form">\n";
// Admin form fields and submit buttons must be rendered first, because // they need to go to the bottom of the form, and so should not be part of // the catch-all call to drupal_render(). $admin = '';
$buttons = drupal_render($form['buttons']);
// Everything else gets rendered here, and is displayed before the admin form // field and the submit buttons. $output .= " <div class="standard">\n";
$output .= "<div class='" . $form['type']['#value'] . "'>\n"; $output .= drupal_render($form['title']); $output .= drupal_render($form['field_page_area']); if ( $form['type']['#value'] == "wide_image") { $output .= drupal_render($form['field_wide_image']); } else { $output .= drupal_render($form['body_field']); } $output .= "<div class='hidden'>\n"; $output .= drupal_render($form); $output .= " </div>\n";
if (!empty($admin)) { $output .= " <div class="admin">\n"; $output .= $admin; $output .= " </div>\n"; } $output .= $buttons; $output .= "</div>\n"; $output .= "</div>\n"; $output .= "</div>\n";
return $output; }
Christopher M. Jones wrote:
What you could do is create overrides for each form element type, adding an id or class based on the name or some other attribute of the form element. I've done this to style specific form elements in forms. That might be simpler than unsetting properties in the form array, and you could do it all from within your template rather than having to create a whole module. Have a look at the theme functions in the API documentation to see how you can do this.
sebastian wrote:
Hi Thanks Lee, others,
My ideal solution would be if the form elements had id or class names, that were unique, so that I could simply hide [display:none] the form elements that I don't feel like the less-tech savvy content admins need to see.
My back-up solution was turning them off as a function, as part of the drupal_render function.
This is for the node creation, of several node types; but right now I am just trying the basic: node->create->page type.
Couple of questions:
- is there a way to inject class and/or node ID's to the basic
node_edit form? I would want the title to always have something like "id="node_title" on ALL of my node edit forms; whether it is for adding a 'page' type, or a new type not yet imagined but latter added. [that way if I am always hiding the 'publishing options' section, for a particular user, it would be hidden site-wide on all forms]
- if it is NOT possible to do the above, then my backup is to use
drupal_render(), as described below. Am I correct that I would just use:
unset($form['name_of_element']); drupal_render($form);
?
- If there is anyway I could take my work [above] and make it into a
module for others to benefit from this change, I would love to contribute this to the drupal community. As I think I must not be the only person who wants to style specific elements on the node-creation page, and right now there is simply no way to target these fields in CSS...
I've never contributed before though, and still learning, so not sure if whatever changes I make will be compatible as a "module"
Thank you so much for your help!!
Sebastian.
Lee Rowlands wrote:
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
These are inserted by the devel_themer module and should not be relied upon
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
The call to drupal_render($form) actually renders the hidden elements such as form id and build id which are needed to determine if the form was submitted by the Form API. If these aren't found, the Form API thinks it wasn't submitted and hence no submit function is called and no data is saved. You need to examine the $form variable and unset (using the unset function) any array members (form elements) you don't want then add a final drupal_render($form) to the end of your output and thiss will add all the hidden stuff (and anything else that still yet to be rendered). I'm assuming you don't have a module here? Otherwise you could do the unsetting in hook_form_alter.
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
Those ids are inserted by the devel themer module. Disable the module and they go away.
sebastian wrote:
Hello Drupalites,
I am tryign to figure this out.
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
If I try and use CSS to access them [perhaps setting display:non for non-tech savy web admins]
Then this works, UNTIL something else changes on the page, and then the numbers all change... SO, I need to find a way to give these random place holding id's actual ID's that relate to the content inside of them [authored by, published, file upload etc.]
I found the hook:
<?php /* * Theming the node form */ function phptemplate_node_form($form) { $output = "\n<div class=\"node-form\">\n"; // Admin form fields and submit buttons must be rendered first, because // they need to go to the bottom of the form, and so should not be part of // the catch-all call to drupal_render(). $admin = ''; $buttons = drupal_render($form['buttons']); // Everything else gets rendered here, and is displayed before the admin form // field and the submit buttons. $output .= " <div class=\"standard\">\n"; $output .= drupal_render($form); $output .= " </div>\n"; if (!empty($admin)) { $output .= " <div class=\"admin\">\n"; $output .= $admin; $output .= " </div>\n"; } $output .= $buttons; $output .= "</div>\n"; return $output; } ?>
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
Also, the function:
drupal_render()
Doesn't really give me much control over how to theme the sub-parts of the form...
Can anyone help me to please give real class and/or id names to the elements of the form?
Thanks!
Sebastian _______________________________________________ themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
I think #thmr_81, thmr_86, #thmr_91, #thmr_98 are generated by devel module.. its just to help devel module highlight certain elements of the theme ... disable it or ignore those ids while theming.
Regards Raffi Hovhannesian http://www.psd2drupal.com
-
On Wed, Nov 11, 2009 at 6:09 AM, Christopher M. Jones cjones@partialflow.com wrote:
Those ids are inserted by the devel themer module. Disable the module and they go away.
sebastian wrote:
Hello Drupalites,
I am tryign to figure this out.
When I have a nord_form, either for creation or editing, I get a lot of id's like: #thmr_81, thmr_86, #thmr_91, #thmr_98
If I try and use CSS to access them [perhaps setting display:non for non-tech savy web admins]
Then this works, UNTIL something else changes on the page, and then the numbers all change... SO, I need to find a way to give these random place holding id's actual ID's that relate to the content inside of them [authored by, published, file upload etc.]
I found the hook:
<?php /* * Theming the node form */ function phptemplate_node_form($form) { $output = "\n<div class=\"node-form\">\n"; // Admin form fields and submit buttons must be rendered first, because // they need to go to the bottom of the form, and so should not be part of // the catch-all call to drupal_render(). $admin = ''; $buttons = drupal_render($form['buttons']); // Everything else gets rendered here, and is displayed before the admin form // field and the submit buttons. $output .= " <div class=\"standard\">\n"; $output .= drupal_render($form); $output .= " </div>\n"; if (!empty($admin)) { $output .= " <div class=\"admin\">\n"; $output .= $admin; $output .= " </div>\n"; } $output .= $buttons; $output .= "</div>\n"; return $output; } ?>
But if I replace $output .= drupal_render($form); with
$output .= drupal_render($form['title']); $output .= drupal_render($form['body_field']); $output .= drupal_render($form['custom_select_field']);
Which are the only three I actually need to have displayed for a non-admin, then the page will NOT save, [no errors, it just reloads the page and erases all my changes]
Also, the function:
drupal_render()
Doesn't really give me much control over how to theme the sub-parts of the form...
Can anyone help me to please give real class and/or id names to the elements of the form?
Thanks!
Sebastian _______________________________________________ themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes