| | 63 | |
|---|
| | 64 | /** Validator auto generation **/ |
|---|
| | 65 | $schema = sfYaml::load(sfConfig::get('sf_config_dir').'/schema.yml'); |
|---|
| | 66 | |
|---|
| | 67 | $fillin = array('fillin' => array('enabled' => 'true')); |
|---|
| | 68 | |
|---|
| | 69 | $fields = array('fields'); |
|---|
| | 70 | |
|---|
| | 71 | foreach ($schema['propel'][sfInflector::underscore($model_class)] as $key => $value) { |
|---|
| | 72 | if (isset($value['required'])) |
|---|
| | 73 | $fields[] = array(sfInflector::underscore($model_class).'{'.$key.'}' => array('required' => array('msg' => $key.' is required.'))); |
|---|
| | 74 | } |
|---|
| | 75 | |
|---|
| | 76 | $validate = array_merge($fillin, array($fields[0] => $fields[1])); |
|---|
| | 77 | |
|---|
| | 78 | $create = fopen($moduleDir.'/validate/create.yml', 'w'); |
|---|
| | 79 | fwrite($create, sfYaml::dump($validate)); |
|---|
| | 80 | fclose($create); |
|---|
| | 81 | |
|---|
| | 82 | $edit = fopen($moduleDir.'/validate/edit.yml', 'w'); |
|---|
| | 83 | fwrite($edit, sfYaml::dump($validate)); |
|---|
| | 84 | fclose($edit); |
|---|