Created
July 25, 2019 06:35
-
-
Save insaurabh/f8d200b0e44f0c9b55485babc51082c5 to your computer and use it in GitHub Desktop.
#craftcms get field type in craftcms 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In service file --> | |
public function getFieldType($fieldName='') | |
{ | |
if ($fieldName === '') { | |
return null; | |
} | |
$fieldType = (new Query()) | |
->select(['type']) | |
->from(['{{%fields}}']) | |
->where(['handle' => $fieldName]) | |
->one(); | |
return $fieldType; | |
} | |
<!-- Now call this function anywhere in your plugin --> | |
$fieldType = CraftAjaxinate::$plugin->craftAjaxinateService->getFieldType('handleName'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment