This is as much as a question as it is a request. If a Page, or a Dataobject has a UploadField, for an image for example, the user is not allowed/able to use them before the Page/DataObject is created and saved.
I am sure I am not the only one who thinks that it is not user friendly to force the user to first create a page before being able to attach an image. As a developer, I understand that the relationship can't be established before the page is in the database but it doesn't make sense for the end user.
Does anyone know if it is going to change in the near future?
A short term solution I found is to only show the UploadField(s) if the page exists in the database:
public function getCMSFields() {
$fields = new FieldList();
$imageUploadField = new UploadField('Image');
$videoUploadField = new UploadField('Video');
$imageUploadField->setConfig('allowedMaxFileNumber', 1);
$videoUploadField->setConfig('allowedMaxFileNumber', 1);
$fields->push(new TextField('Title'));
$fields->push(new HTMLEditorField('Content'));
if ($this->ID) {
$fields->push($imageUploadField);
$fields->push($videoUploadField);
}
$fields->push(new TextField('Source'));
$fields->push(new TextareaField('Embed', 'Video embed code'));
return $fields;
}
Thanks