Jump to content
gebeer

Add description to form field object - method missing

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?

Share this post


Link to post
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

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By NehaPillai
      Hello Everyone, I was trying to update SEO meta title, description and meta keywords for my website in Process Wire CMS but it saving in the backend but it is not reflecting on my website, Please help me regarding this error. Please find below attached screen shot for your ref. TIA.


    • By depone
      Hey all,
      I am trying to prevent the display of descriptions for images in default language while user browses site with alternative language.
      In a gallery my goal would be to display the same images, and hide the description that I am using as captions. As a hack I could decide based on tags, but this causes extra workload for the editors of the site, and seems less robust than a built in query.
      Any hints are highly appreciated.
    • By ---
      I've added a hook after the '"ProcessPageEdit::buildFormContent" event.
      I've added a new config option to the language settings:
      public function beforeAdminProcessPageEditBuildFormContent (HookEvent $event) { $editPage = $this->getPage(wire('input')->get('id')); if ($editPage->template->name == 'language') { // only add field when editing language page $field = wire('modules')->get('InputfieldText'); $field->attr('name+id', 'locale'); $field->label = __('Locale'); $event->return->insertAfter($field, $event->return->getChildByName('title')); } } I've also created a field (Setup > Fields > Add new) which I've also named 'locale'.
      The field is displayed, but the value isn't saved when I click the save button. How do I make sure the input of the field is saved as well? And how can I access the stored value once it's saved?
    • By Uonze
      I have a page configured with a repeater, inside the repeater there is a input file with description.
      I havent updated the website content in a while but today when I tried to add a new file, the file upload worked correctly but I can't insert a description in the file. Also the previously created instances have the correct description but I can't update them.
      I added a attachment of the page edit view for better understaning.
      Also the logs don't show any errors.

    • By Lance O.
      I have a template that includes an image field that supports multiple images. The images uploaded to this field include a description field.
      If one of these images is embedded into a textarea field (i.e. Body), should the image description will be inserted into the image's alt attribute when embedding the image?
      I always assumed that it would, but there is a separate option to add an alt attribute when inserting the image.
      Is the purpose of the description field purely for use with the API and unnecessary for images that are intended to be embedded within a textarea field?
      I guess I need clarification as to how this works. Either something changed, or I never understood the differences between the image description and the alt attribute as it is used in ProcessWire.
      I'm currently using ProcessWire 3.0.15.
×
×
  • Create New...