form3

parent 0d28b464
......@@ -30,8 +30,8 @@ import {
</div>
<div class="form-group">
<label>Ημερομηνία Γέννησης</label>
<input type="date" [(ngModel)]="student.birthdate"
class="form-control" name="birthdate" />
<input type="date" [(ngModel)]="student.birthDate"
class="form-control" name="birthDate" />
</div>
<input type="submit" [disabled]="!studentform.valid" value="Υποβολή" class="btn btn-success" />
</form>
......@@ -49,18 +49,93 @@ export default class Form3 {
onSubmit(studentform: any) {
// console.log(studentform);
// console.log(studentform.surname + "..." + studentform.name + "..." + studentform.address+ "..." + studentform.birthdate);
this.student._links = '{"type": {"href": "http://eepal.dev/drupal/rest/type/node/student"}}';
this.student.type = [{"target_id": "student"}];
this.student._links = {
"self":{"href":"http:\/\/eepal.dev\/drupal\/admin\/structure\/student\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/student\/student"},
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/user_id":[
{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json","lang":"en"}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/studentclass_id":[
{"href":"http:\/\/eepal.dev\/drupal\/admin\/structure\/student_class\/1?_format=hal_json","lang":"en"}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/revision_uid":[
{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json"}
]
};
this.student.langcode = [
{"value":"en","lang":"en"}
];
this.student.embedded = {
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/user_id":[
{
"_links":{
"self":{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/user\/user"}
},
"uuid":[
{"value":"1291f55b-3258-400f-8a0a-634252e13552"}
],
"lang":"en"
}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/studentclass_id":[
{
"_links":{
"self":{"href":"http:\/\/eepal.dev\/drupal\/admin\/structure\/student_class\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/student_class\/student_class"}
},
"uuid":[
{"value":"eaf42da6-290a-49c0-8d86-551bca2023fa"}
],
"lang":"en"
}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/revision_uid":[
{
"_links":{
"self":{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/user\/user"}
},
"uuid":[
{"value":"1291f55b-3258-400f-8a0a-634252e13552"}
]
}
]
};
this.student.name = [
{
"value":"Haris"
}
];
this.student.surname = [
{
"value":"Papadopoulos"
}
];
this.student.address = [
{
"value":"Kimonos Voga 36"
}
];
this.student.birthdate = [
{
"value":"2001-10-01"
}
];
let headers = {
"Authorization": "Basic YWRtaW46MTIzcXdl", // encoded user/pass - this is admin/123qwe
"Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user/pass - this is admin/123qwe
"Content-Type": "application/hal+json",
"X-CSRF-Token": "aAjJxSqCHxU6ticjobl1GVVM-sGh26MnYgQ7CwEGyEc"
};
console.log(this.student);
this.http.post('http://eepal.dev/drupal/entity/student',studentform,headers)
this.http.post('http://eepal.dev/drupal/entity/student',this.student,headers)
// Call map on the response observable to get the parsed people object
.map((res: Response) => res.json())
.subscribe(success => console.log("success post"), // put the data returned from the server in our variable
error => console.log("Error HTTP GET Service"), // in case of failure show this message
() => console.log("write this message anyway"));//run this code in all cases);
() => console.log("write this message anyway"));//run this code in all cases);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment