ID's on Div rather than Form Elements
Permalink Browser Info Environment
Really just a suggestion (it's pretty hard to have a complaint about an awesome free additional to one's toolbox) but is there some way you could force the id="question#" to the containing div rather than the input.
It would make for far more control over positioning of form elements, dividing your form into sections etc.
My 'havEaGoHacker' attempt was to add
to the div id in the ajax_tableless_layout.php. It seemed to almost work but not quite and anyway would have resulted in there being two identical ID's on the page.
Surely if this could be made to work then the id on the input would be superfluous (div#questionNumber input).
Anyway I quess there's is a good reason for this- some legacy thing from the way the core form works perhaps?
if this is the case could something along the lines of
be made to work by someone with the php savvy?
It would make for far more control over positioning of form elements, dividing your form into sections etc.
My 'havEaGoHacker' attempt was to add
id="<?php echo $question['input']; ?>"
to the div id in the ajax_tableless_layout.php. It seemed to almost work but not quite and anyway would have resulted in there being two identical ID's on the page.
Surely if this could be made to work then the id on the input would be superfluous (div#questionNumber input).
Anyway I quess there's is a good reason for this- some legacy thing from the way the core form works perhaps?
if this is the case could something along the lines of
echo $question['input'+'echo t('div')']
be made to work by someone with the php savvy?
Type: | Discussion |
---|---|
Status: | New |
I wish it were possible to do that, but the core form block attaches the id's to the inputs, so there's no way to change that from a custom template (unless you wanted to parse out the html strings of the markup and change it using a series of complex and error-prone regexes -- which you really don't want to do). If you're okay requiring javascript, you might want to try using jquery to manipulate the DOM and remove the ids from one place and add them to another.
Would it not be possible to recycle the id from the input and using some stringing together technique such as
leaving the markup
I'm too unfamiliar with php to know if and why not this wouldn't work..
<php $stringFromCoreFormInput = "questionNo"; $string = "container"; $stringForInputContainer = $string1.$string2; ?> <div id="<?php echo t('$stringForInputContainer'); ?>" />
leaving the markup
<div id="questionNcontainer"> <input id="questionN"> </div>
I'm too unfamiliar with php to know if and why not this wouldn't work..
unless of course that is what you meant above by parsing out html strings!
anyway, it's not really your job to teach me php, just wondered if it was worth digging into or a complete blackhole that would be better spent writing javascript
anyway, it's not really your job to teach me php, just wondered if it was worth digging into or a complete blackhole that would be better spent writing javascript
Yes, that's what I meant by "parsing out html strings".
And yes, your time would be much better spent doing it via jquery. Would probably be a 30 minute job that way as opposed to many boring hours via PHP.
And yes, your time would be much better spent doing it via jquery. Would probably be a 30 minute job that way as opposed to many boring hours via PHP.
It probably would work, eventually (after enough hacking and testing and debugging to make sure you account for every possibility). I personally don't have the time to do it, but you're more than welcome to try it yourself (the code is free and open-source).
-Jordan
-Jordan
Well, thanks for the input. It's off to the jQuery room for me then : )