Jump to content
OLSA

List of reserved words

Recommended Posts

Hello,

I had a problem with this part of code:

$field = $modules->get("InputfieldSelect");
$field->label = $el['label-children'];
$field->attr('id+name','children'); //=> this line was a problem
$field->attr("wrapClass", "large-4 columns");
$options = array('0','1','2','3','4','5','6','7','8','9','+10');
foreach($options as $k => $v) {
  $field->addOption($k, $v);
}
$form->append($field);

and later in some loop I had a trouble

foreach( $form->children as $f ) {
...
}

Because I am still learning Processwire maybe it would be nice to have some kind of "List of reserved words".

My mistake was that I didn't give importance about "children" in this part: 

$field->attr('id+name','children'); 

because I was thinking: ok it will create select field with id="children" and name="children"

But that was wrong :)

Regards,

Sasa

Share this post


Link to post
Share on other sites

Just stumbled upon a failing field name, too.

In PW3 "files" is reserved, as not only those names from LostKobrakai's mentioned array are considered reserved, but everything in $wire too.

https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessField/ProcessField.module#L1439

and in PW3 there's WireFileTools class which populates $files

  • Like 1

Share this post


Link to post
Share on other sites

Using your own two or three character prefix (plus _ or -) to name identifiers can be of help no matter what system we use (css, php, js, etc...). This way it is also easy to tell what belongs to your code and what not. It helps in this issue, but also helps others dealing with your code. Sure, the practice of prefixing is not a bulletproof solution, but it is unlikely that one runs into this issue when sticking to it.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...