822). What is necessary when we need to create a new field in craft?
[A]Type of the input
[B]Type of the output
[C] Type of the field
[D]Type of argument
Show Answer
Correct Answer: Type of the field
Notes:
Answer: c
Explanation: Whenever someone creates a new field in Craft, they must specify what type of field it is. They are organized into Field Groups for convenience, but Field Groups have very little relevance anywhere else in the system.
823). What does the getInputHtml() return?
[A]Input
[B]Fieldtype’s input HTML
[C]Array
[D]Value
Show Answer
Correct Answer: Fieldtype’s input HTML
Notes:
Answer: b
Explanation: The method getInputHtml() returns a fieldtype’s input HTML. It accepts two arguments: $name and $value.
824). How many arguments does the getInputHtml() accept?
Show Answer
Correct Answer: 2
Notes:
Answer: b
Explanation: The method getInputHtml() returns a fieldtype’s input HTML. The method getInputHtml(0 accepts two arguments: $name and $value. $name is the name you should assign your HTML input name= attribute, and $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
825). Which is the method used to process on the input post data before it is saved to the database?
[A]prep()
[B]settings()
[C]defineSettings()
[D]prepSettings()
Show Answer
Correct Answer: prepSettings()
Notes:
Answer: d
Explanation: defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc). If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
826). What is the purpose of the parameter $name ?
[A]Document Name
[B]Input Name
[C] Output Name
[D] ID
Show Answer
Correct Answer: Input Name
Notes:
Answer: b
Explanation: getinputhtml() accepts two arguments: $name and $value. The parameter $name is the name you should assign your HTML input name= attribute.
827). What does the method defineSettings() return?
[A]Array of settings name
[B]Array of hash key
[C] Array of strings
[D]Array of objects
Show Answer
Correct Answer: Array of settings name
Notes:
Answer: a
Explanation: The defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc). If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
828). What is the purpose of the parameter $value?
[A]Field’s expected value
[B]Field’s previous value
[C]Field’s current value
[D]Field’s probability value
Show Answer
Correct Answer: Field’s current value
Notes:
Answer: c
Explanation: getinputhtml() accepts two arguments: $name and $value. The parameter $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
829). When does the defineContentAttribute() method return a false?
[A]Data stored in different table
[B] Data stored in its own table
[C]Data is not stored at all
[D]Data is not obtained
Show Answer
Correct Answer: Data stored in its own table
Notes:
Answer: b
Explanation: If your fieldtype is storing data in its own table, and doesn’t have any use for a column within the main content table, you may also set defineContentAttribute() to return false. By default, BaseFieldType sets the column to VARCHAR(255), but you can override that with defineContentAttribute().
830). How many events does the BaseFieldType provide?
Show Answer
Correct Answer: 3
Notes:
Answer: c
Explanation: BaseFieldType provides three events that you can latch code onto:
onBeforeSave() : Called right before a field is saved.
onAfterSave() : Called right after a field is saved, and $this->model->id is set.
onAfterElementSave() : Called right after an element is saved, and $this->element->id is set.
831). Which method is called right before a field is saved?
[A]onBeforeSave()
[B]BeforeSave()
[C]SaveBefore()
[D]onSave()
Show Answer
Correct Answer: onBeforeSave()
Notes:
Answer: a
Explanation: BaseFieldType provides three events that you can latch code onto:onBeforeSave(), onAfterSave() and onAfterElementSave(). The method onBeforeSave() is called right before a field is saved.