Answer the question
In order to leave comments, you need to log in
How to create a file field for an entity?
I have an entity one of the fields of which should be a file.
Well, let's say this:
class MessageTable extends \Bitrix\Main\Entity\DataManager
{
public static function getMap()
{
return array(
new Entity\IntegerField('ID', array(
'primary' => true,
'autocomplete' => true
)),
new Entity\IntegerField('AUTHOR', array(
'required' => true
)),
new Entity\StringField('TEXT'),
new Entity\IntegerField('FILE')
);
}
}
Answer the question
In order to leave comments, you need to log in
There is another way and it is quite simple: you write that the entity works with properties and add a UF_* property of the file type (or a file on disk) and Bitrix does everything for you. The only thing is there are a few restrictions:
- The field is called with the UF_ prefix
- Validation according to the field settings
- You need to add uf separately
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question