Witam, mam problem związany z modyfikacją formularza stworzonego za pomocą admin-generatora.
Tak wygląda opis obiektu Query w schema.yml:
query:
id:
created_at:
status_changed_at: { type: TIMESTAMP }
client_id: { type: integer, foreignTable: sf_guard_user, foreignReference: id,required: true }
supervisor_id: { type: integer, foreignTable: sf_guard_user, foreignReference: id,required: true }
villa_id:
name: { type: VARCHAR, size: '50', required: true }
email: { type: VARCHAR, size: '50', required: true }
phone_no: { type: VARCHAR, size: '50', required: true }
mobile_no: { type: VARCHAR, size: '50', required: true }
skype: { type: VARCHAR, size: '100', required: true }
period_from: { type: TIMESTAMP, required: true }
period_to: { type: TIMESTAMP, required: true }
nights_no: { type: INTEGER, required: true }
message: { type: LONGVARCHAR, required: true }
family_info: { type: LONGVARCHAR, required: true }
owner_message: { type: LONGVARCHAR, required: true }
adult_no: { type: INTEGER, required: true }
children_no: { type: INTEGER, required: true }
children_age: { type: VARCHAR, size: '50', required: true }
ip: { type: VARCHAR, size: '25', required: true }
status: { type: VARCHAR, size: '1', required: true, default: '0' }
visible: { type: BOOLEAN, required: true, default: true }
Tak wygląda generator.yml w /backend/modules/query/config/:
generator:
class: sfPropelAdminGenerator
param:
model_class: Query
theme: default
fields:
created_at: { name: Utworzono, params: class="cal" }
status_changed_at: { name: Status zmieniono }
client_id: { name: Klient }
supervisor_id: { name: Opiekun }
villa_id: { name: ID willi }
name: { name: Imię i nazwisko }
phone_no: { name: Nr tel. stacjonarny }
mobile_no: { name: Nr tel. komórkowy }
period_from: { name: Przyjazd }
period_to: { name: Wyjazd }
nights_no: { name: Liczba nocy }
message: { name: Treść wiadomości }
family_info: { name: Info o rodzinie }
owner_message: { name: Wiadomość dla gospodarza }
adult_no: { name: Liczba dorosłych }
children_no: { name: Liczba dzieci }
children_age: { name: Wiek dzieci }
ip: { name: IP }
visible: { name: Widoczny }
edit:
title: Edycja zapytania %%id%%
display:
"Willa": [villa_id]
"Przebieg": [status,created_at,status_changed_at]
"Użytkownicy": [client_id, supervisor_id]
"Dane personalne": [name, email, phone_no, mobile_no, skype]
"Zakres dat": [period_from, period_to]
"Goście": [adult_no, children_no, children_age, family_info]
Do takiego obiektu został wygenerowany formularz BaseQueryForm.class.php w /lib/form/base:
class BaseQueryForm extends BaseFormPropel
{
public function setup()
{
'id' => new sfWidgetFormInputHidden(),
'created_at' => new sfWidgetFormDateTime(),
'status_changed_at' => new sfWidgetFormDateTime(),
'client_id' => new sfWidgetFormPropelChoice
(array('model' => 'sfGuardUser', 'add_empty' => false)), 'supervisor_id' => new sfWidgetFormPropelChoice
(array('model' => 'sfGuardUser', 'add_empty' => false)), 'villa_id' => new sfWidgetFormPropelChoice
(array('model' => 'Villa', 'add_empty' => true)), 'name' => new sfWidgetFormInput(),
'email' => new sfWidgetFormInput(),
'phone_no' => new sfWidgetFormInput(),
'mobile_no' => new sfWidgetFormInput(),
'skype' => new sfWidgetFormInput(),
'period_from' => new sfWidgetFormDateTime(),
'period_to' => new sfWidgetFormDateTime(),
'nights_no' => new sfWidgetFormInput(),
'message' => new sfWidgetFormTextarea(),
'family_info' => new sfWidgetFormTextarea(),
'owner_message' => new sfWidgetFormTextarea(),
'adult_no' => new sfWidgetFormInput(),
'children_no' => new sfWidgetFormInput(),
'children_age' => new sfWidgetFormInput(),
'ip' => new sfWidgetFormInput(),
'status' => new sfWidgetFormInput(),
'visible' => new sfWidgetFormInputCheckbox(),
));
$this->setValidators(array( 'id' => new sfValidatorPropelChoice
(array('model' => 'Query', 'column' => 'id', 'required' => false)), 'created_at' => new sfValidatorDateTime
(array('required' => false)), 'status_changed_at' => new sfValidatorDateTime
(array('required' => false)), 'client_id' => new sfValidatorPropelChoice
(array('model' => 'sfGuardUser', 'column' => 'id')), 'supervisor_id' => new sfValidatorPropelChoice
(array('model' => 'sfGuardUser', 'column' => 'id')), 'villa_id' => new sfValidatorPropelChoice
(array('model' => 'Villa', 'column' => 'id', 'required' => false)), 'name' => new sfValidatorString
(array('max_length' => 50)), 'email' => new sfValidatorString
(array('max_length' => 50)), 'phone_no' => new sfValidatorString
(array('max_length' => 50)), 'mobile_no' => new sfValidatorString
(array('max_length' => 50)), 'skype' => new sfValidatorString
(array('max_length' => 100)), 'period_from' => new sfValidatorDateTime(),
'period_to' => new sfValidatorDateTime(),
'nights_no' => new sfValidatorInteger(),
'message' => new sfValidatorString(),
'family_info' => new sfValidatorString(),
'owner_message' => new sfValidatorString(),
'adult_no' => new sfValidatorInteger(),
'children_no' => new sfValidatorInteger(),
'children_age' => new sfValidatorString
(array('max_length' => 50)), 'ip' => new sfValidatorString
(array('max_length' => 25)), 'status' => new sfValidatorString
(array('max_length' => 1)), 'visible' => new sfValidatorBoolean(),
));
$this->widgetSchema->setNameFormat('query[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
public function getModelName()
{
return 'Query';
}
}
Zaś ja chciałem zmodyfikować pola z datą, tzn. created_at, status_changed_at, period_from i period_to. Zacząłem więc od powyższego:
QueryForm.class.php w lib/form
class QueryForm extends BaseQueryForm
{
public function configure()
{
$this->widgetSchema['period_from'] = new sfWidgetFormJQueryDate
(array( 'image'=>'/images/icons/calendar_view_month.gif',
'format' => '%day%/%month%/%year%')
);
}
}
Niestety, nie przynosi to żadnego efektu. Mało tego, wprowadzanie jakiejkolwiek zmiany do QueryForm, a nawet BaseQueryForm (tak, wiem, że się nie powinno, ale tylko do testu (IMG:
style_emoticons/default/smile.gif) jak np. usunięcie widżetu, zmiana widżetu daty na zwykły input, nic nie zmienia. Tak, mam: podłączone jquery, jquery-ui, style do jquery-ui, zainstalowany plugin sfFormExtraPlugin. Plugin do "layout" do jquery działa świetnie. Czy ktoś wie może, czemu modyfikacja tych formularzy nie zmienia mi widoku edycji w admin generatorze?