Jump to content

Add description to form field object - method missing


gebeer
 Share

Recommended Posts

Hello,

I'm trying to add a custom description to my formfield

$serverField = $modules->get("InputfieldText");
$serverField->label = "Server Name";
$serverField->attr("id+name","servername");
$serverField->attr("value",$prefillServer);
$serverField->attr("class","form-control");
$serverField->description("description","Desc");// need right syntax here. Or is the method missing
$serverForm->append($serverField);

I get an error:

Method InputfieldText::description does not exist

I looked at InputfieldText.module and there is no method for adding a description. Shouldn't there be one?

Couldn't find anything in the API cheatsheet that would let me do that.

How would I then go about adding a description to a form field?

Link to comment
Share on other sites


$serverField = $modules->get("InputfieldText");

$serverField->label = "Server Name";

$serverField->attr("id+name","servername");

$serverField->attr("value",$prefillServer);

$serverField->attr("class","form-control");

$serverField->description = "this is my description";//this is the right syntax :-)

$serverForm->append($serverField);

Edited by kongondo
edited; added a missing = and removed extra ()
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...