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
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
AndYMacKay
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
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.
AndYMacKay replied on at Permalink Reply
AndYMacKay
Would it not be possible to recycle the id from the input and using some stringing together technique such as
<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..
AndYMacKay replied on at Permalink Reply
AndYMacKay
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
jordanlev replied on at Permalink Reply
jordanlev
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.
jordanlev replied on at Permalink Reply
jordanlev
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
AndYMacKay replied on at Permalink Reply
AndYMacKay
Well, thanks for the input. It's off to the jQuery room for me then : )

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.