Obtaining input ID

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
User avatar
Ricko97
Forum Members
Forum Members
Posts: 65
Joined: Wed Jan 07, 2009 10:14 pm

Obtaining input ID

Post by Ricko97 »

Hello,

I am looking for an appropriate method of obtaining the ID of a newly created form element. For example, in a typical module we might have something like this:

Code: Select all

$smarty->assign('comment_input', $this->CreateTextarea(false, $id, '', 'comment_body', '', $id.'comment_body', '', '', '', ''));
The resulting HTML for the text area is:

Code: Select all

<textarea name="cntnt01comment_body" cols="" rows="" class="cms_textarea" id="cntnt01comment_body"></textarea>
I need a way of obtaining the contents of the "id" attribute from within the same part of the module. I tried this:

Code: Select all

$bbcode_toolbar = $this->BBCode->BBCToolbar($id.'comment_body');
...but it only passes the first character ("c") to the BBCToolbar function.

Am I doing something wrong? Is there a better way of doing it? Or can I simply hardcode it like $this->BBCode->BBCToolbar("cntnt01comment_body"); ?

Any help appreciated. :)

EDIT: ahem. Seems I've managed to figure it out myself afterall. The way I wrote the BBCToolbar function assumed that the only parameter it receives is an array ($params['input']), whereas it was actually receiving one variable containing a string. I changed it to use "$input" instead and it's working fine now. But if there's more of a "proper" way than simply using $id.'whatever', I'd like to know :) thanks.
Last edited by Ricko97 on Thu Dec 02, 2010 12:31 pm, edited 1 time in total.
Locked

Return to “Developers Discussion”