Core/getFieldById

From PunchCMS
Jump to: navigation, search

PCMS_Client->getFieldById(fieldId)

Overview

Get a field with a specific id from the CMS. This is usually used to transfer the id of File and Image field types to external scripts.

Arguments

fieldId [integer]
Id of the field you are looking for.

Returns

If a field is found matching the id this method returns a valid Field object. Otherwise NULL. That way you can test if you get a valid return using the is_object() method.

Example

$objCms = PCMS_Client::getInstance();
 
$objField = $objCms->getFieldById(33442);
if (is_object($objField)) {
    // Found Field with id 33442.
}